In a VS2017 ASP.NET MVC project I've noticed that my views aren't syntax checked on build/compile even though I have set
true. The project is now on MVC 5 but has been upgraded from some earlier version. It also started out being set to AnyCPU but it's now set to x64 (we need a lot of data in memory sometimes, and we always deploy to x64, so...).
I've checked that the
.csproj contains the build target that has been mentioned in various places, including several in SO answers. I've tried a few variations, but none has worked.
This is the one that was present but commented out in the
.csproj when I started investigating:
<Target Name="BuildViews" Condition="'$(MvcBuildViews)'=='true'" AfterTargets="Build"> <Message Importance="normal" Text="Precompiling views" /> <AspNetCompiler VirtualPath="temp" PhysicalPath="$(WebProjectOutputDir)" /> </Target>
If i uncomment it, I get a build error (I've manually translated it from Swedish):
Failed to read the file or assembly MyProjectName or one of its dependencies. An attempt to read a program with invalid format was made.
It was suggested here to specify the x64 ASP.NET compiler:
Add this below the
<AspNetToolPath Condition="'$(Platform)' == 'x64'">$(windir)\Microsoft.NET\Framework64\v4.0.30319</AspNetToolPath>
And add attribute
ToolPath="$(AspNetToolPath)" to the target's
Doing so results in another error (again translated by me from Swedish):
Failed to read the file or assembly System.Runtime.InteropServices.RuntimeInformation, Version=22.214.171.124, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a or one of its dependencies. The found assembly's manifest definition doesn't match the assembly reference. (Exception from HRESULT: 0x80131040)
The assembly in question is pulled into the project by our use of a Stripe card payment NuGet package, which was added after the project was changed from AnyCPU to x64. The
System.Runtime.InteropServices.RuntimeInformation package is installed in version 4.3.0. The
web.config contains this binding redirect (why don't the version numbers match 4.3.0?):
<dependentAssembly> <assemblyIdentity name="System.Runtime.InteropServices.RuntimeInformation" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-126.96.36.199" newVersion="188.8.131.52"/> </dependentAssembly>
At this point, I'm out of ideas, what to try next. Can anyone help?
Try to register that dll into GAC:
update-package -reinstall under Tools-->Nuget Package Manager-->Package Manager Console
2) open developer command prompt for VS as Administrator and then type:
cd C:\Users\xxx\.nuget\packages\system.runtime.interopservices.runtimeinformation\4.3.0\lib\net45 gacutil /i System.Runtime.InteropServices.RuntimeInformation.dll
Also, you can download
system.runtime.interopservices.runtimeinformation nuget package version
After that, register that dll under
Besides, there is a similar issue.
User contributions licensed under CC BY-SA 3.0