After downloading ASP.NET MVC 5.x template, I update the connection string, restore NuGet packages and then try to run Update-Database command in Package Manager Console, but I consistently get the following error:
Could not load file or assembly 'Castle.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
I was able to solve this once by removing all packages and adding them back one at a time, but this is extremely time-consuming.
I have had this same experience with both the Angular and Multipage versions, and I am using VS2017 Community.
What am I doing wrong?
in the Web project's web.config it reads:
<dependentAssembly>
<assemblyIdentity name="Castle.Core" publicKeyToken="407dd0808d44fbdc" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
</dependentAssembly>
You can remove that binding redirect.
Related
I am seeing these errors during builds.
C:\Program Files (x86)\Microsoft WCF Data Services\5.6.4\bin\.NETFramework\Microsoft.Data.Services.Client.xml' contains invalid characters.
C:\Program Files (x86)\Microsoft WCF Data Services\5.6.4\bin\.NETFramework\Microsoft.Data.OData.xml' contains invalid characters
C:\Program Files (x86)\Microsoft WCF Data Services\5.6.4\bin\.NETFramework\Microsoft.Data.Edm.xml' contains invalid characters.
C:\Program Files (x86)\Microsoft WCF Data Services\5.6.4\bin\.NETFramework\System.Spatial.xml' contains invalid characters.
I dont get them locally when I run MsBuild with the same arguements, and I can even run MSBuild on the private build agent just fine too.
I have other projects using OctoPack just fine, and using these packages. I am going to double check them very carefully because the other ones work just fine.
The problem is solved by upgrading the affected packages from 5.6.4 to 5.7.0 (current latest build).
I spent a good couple of hours trying to figure this out. I figured I could save others the time by posting a question I would have asked, and the answer too.
Also make sure that the App.config/web.config of your main target also has binding redirects:
<dependentAssembly>
<assemblyIdentity name="Microsoft.Data.Services.Client" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.7.0.0" newVersion="5.7.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Data.OData" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.7.0.0" newVersion="5.7.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Microsoft.Data.Edm" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-5.7.0.0" newVersion="5.7.0.0" />
</dependentAssembly>
You may have these in a service/utility project within your solution, but if they are not present in the main config file of your "deployable" target, they will be ignored and you might still pick up references to
C:\Program Files (x86)\Microsoft WCF Data Services\5.6.4
Versions of the DLLs, and not the NuGet packaged versions you intended, from your "packages" folder.
We have TFS build machine configured to build source code from TFS. On this machine we had Team Foundation Server 2013 together with Microsoft Build Tools 2013 installed and then recently, we installed Microsoft Build Tools 2015. In the build defintion, we put /tv:14.0 for MSBuild arguments to indicate we want to use version 14.0 of MSBuild. Also, we set the perform code analysis to be false so that it won't perform code analysis.
However, when we queue a build, it failed with given errors:
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\CodeAnalysis\Microsoft.CodeAnalysis.targets (214): The source file for this compilation can be found at: "C:\Users\tfsservice\AppData\Local\Temp\b54ca1bb-e696-4214-a196-5c79c32345cd.txt"
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\CodeAnalysis\Microsoft.CodeAnalysis.targets (214): An error has occurred during compilation. error CS1705: Assembly 'Microsoft.Build.Utilities.Core, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' uses 'Microsoft.Build.Framework, Version=14.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' which has a higher version than referenced assembly 'Microsoft.Build.Framework, Version=12.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v14.0\CodeAnalysis\Microsoft.CodeAnalysis.targets (214): The "SetEnvironmentVariable" task was not found. Check the following: 1.) The name of the task in the project file is the same as the name of the task class. 2.) The task class is "public" and implements the Microsoft.Build.Framework.ITask interface. 3.) The task is correctly declared with <UsingTask> in the project file, or in the *.tasks files located in the "C:\Program Files (x86)\MSBuild\14.0\bin\amd64" directory.
Does anybody experience this issue before?
It seems like the Microsoft.Build.Utilities.Core was referenced to the incorrect version of Microsoft.Build.Framework.
However, in MSBuild.exe.config, this assembly is redirected corectlly
<dependentAssembly>
<assemblyIdentity name="Microsoft.Build.Framework" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-99.9.9.9" newVersion="14.0.0.0"/>
</dependentAssembly>
Any helps are appreciated.
P.s. The solution we want to build is a visual c++ solution upgraded from VS 2013 to VS 2015.
Seems that many other community members have the similar issue, the /tv:14.0 argument doesn't work. Check this link for the detailed information.
The workaround is: instead of using the /tv:14.0 argument, you need to customize the tfs build process template to set ToolPath of the Run MSBuild for Project to target to MSBuild14; and set ToolVersion to "14.0".
When installing the servicestack.razor-package, it transforms the web.config file
<assemblies>
<add assembly="System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
</assemblies>
When developing this runs fine, but when I'm deploying the solution to Windows Server 2012, the assembly cannot be found, giving me this error when loading the application:
<assemblies>
<add assembly="System.Web.WebPages.Razor, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
</assemblies>
Can anyone please give me any insight to how I can get my environment to host my application? Copying this single dll or installing Visual Studio on my server isn't my preferred option.
Thanks!
If System.Web.WebPages.Razor is a dependency that your application needs and it's not in the GAC of your server then you do need to copy that file.
MVC and Razor support are not included in the standard .NET Framework deployment, because they should be deployed as part of the solution.
You could install Microsoft WebMatrix v1 on the server, which should then add that library to the GAC on your server, but to me that seems like overkill when copying should be sufficient.
I would copy System.Web.WebPages.Razor.dll to the bin folder.
I moved a project from MVC 3 to MVC 4 a while ago now.
when I build, I get the messages
1> No way to resolve conflict between "System.Web.Mvc, Version=3.0.0.0 ..." and , Version=2.0.0.0
1> Consider app.config remapping of assembly "System.Web.WebPages ..." from Version "1.0.0.0" to Version "2.0.0.0" to solve conflict and get rid of warning.
1> Consider app.config remapping of assembly "System.Web.WebPages.Razorfrom Version "1.0.0.0" [c:\Program Files (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v1.0\Assemblies\System.Web.WebPages.Razor.dll] to Version "2.0.0.0" [C:\Users\OEM\documents\visual studio 2012\Projects\DabTrial\packages\Microsoft.AspNet.WebPages.2.0.30506.0\lib\net40\System.Web.WebPages.Razor.dll] to solve conflict and get rid of warning.
and so on.
When I look at references, they are all the later versions, and the web.config only refers to the later versions. When I search the entire solution directory by the public key token (in windows explorer) I find no XML type files with references to the earlier versions.
obviously the path to the files is different, but I cannot find where the compiler is being directed to the path for the earlier .dll file.
The project builds and runs fine, but I assume the compiler is suggesting these changes for a reason. Thanks for any help.
Your nuget dependencies are probably referencing the MVC3 version. You can try putting the following into your web config to force the MVC4 version:
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-3.0.0.0" newVersion="4.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
You could also try running the following in the Package Manager Console
Update-Package -Reinstall
You have to have at least version 2.1 of nuget for this command but it will update your packages and retarget them if you have updated .NET. You can check this post for more information.
Retargeting solution from .Net 4.0 to 4.5 - how to retarget the NuGet packages?
I also had such problems. I did just two things:
updated System.Web.Mvc and all dependencies to the last version (5.2.3)
Rebuild all solution (I did using "Solution -> Clean Solution", then "Solution -> Build Solution")
Try setting AutoGenerateBindingRedirects to true in the project file.
I'm try to build project that use LinqToExcel library. Additionally, I'm use log4net to write logs.
My problem started when I'm tryomg to run this lines of code:
var excel = new ExcelQueryFactory(ExcelPath);
return (from r in excel.Worksheet<RowDetails>(company.Name)
select r).Count();
This line thrown exception:
ERROR MyProj.Program Main:System.IO.FileLoadException: Could not load
file or assembly 'log4net, Version=1.2.11.0, Culture=neutral,
PublicKeyToken=669e0ddf0bb1aa2a' or one of its dependencies. The
located assembly's manifest definition does not match the assembly
reference. (Exception from HRESULT: 0x80131040) File name: 'log4net,
Version=1.2.11.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a'
It's important to note that I'm successful to use log4net before this line.
I would appreciate any help.
Thanks a lots!
As marc_s pointed out, this problem usually appears when trying to load different versions of the same assembly. Make sure, that your project uses the same assembly version as the LinqToExcel library, which is also dependent on log4net. Also any other libraries should use the same assembly version. To solve the issue, you can also try to use assembly redirect in your app.config like so:
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="log4net" publicKeyToken="669e0ddf0bb1aa2a" culture="neutral" />
<bindingRedirect oldVersion="1.2.10.0" newVersion="1.2.11.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
try to install it using nuget
Install-Package log4net -Version 2.0.0
Version 2.0.0 is for log4net 1.2.11
I'm having similar problem. I think that the problem is in LinqtoExcel referencing Log4Net version 1.2.11, and you have referenced Log4Net sepratly and you get latest 1.2.13 version. In build output you'll end up with 1.2.13, and when LintoExcel calls Log4Net it expects 1.2.11 and error ocures.
I got this issue after upgrading log4net through NuGet, only to find that the newer version was signed with a different key.
You can grab the 'oldkey' version from the apache log4net site and then it worked for me.