I am trying to compile my project named MyAssembly, and when including other assembly named ExternalAssembly that also references NLog, I get the following error :
Assembly ExternalAssembly, Version=1.0.0.0 uses NLog, Version=2.1.0.0 which has a higher version than referenced assembly NLog, Version=2.0.0.0
I went to my app config and added the following entry:
<?xml version="1.0"?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="NLog" publicKeyToken="5120E14C03D0593C" culture="neutral"/>
<bindingRedirect oldVersion="2.0.0.0" newVersion="2.1.0.0"/>
</dependentAssembly>
...
But I still get the same error.
Any ideas about why it is not working, and how to fix this error?
To solve this issue I had to upgrade the NLog reference of my project to match the one of the third party (2.1.0.0).
Related
The following error appeared after deploying the application to IIS, although it's NOT the first time to deploy this web application, but this is a new update to it!
Could not load file or assembly 'System.Web.Mvc(1)' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
It looks like you tried to install the ASP.NET MVC dependency twice since you have System.Web.Mvc(1) instead of plain System.Web.Mvc, so please take note of that. More than likely, that other assembly you are using is referencing the old dll, so make sure you have the right newVersion value under BindingRedirect in your Web.config file, as it should look something like this:
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35"/>
<bindingRedirect oldVersion="0.0.0.0-5.2.3.0" newVersion="5.2.3.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
I got the following error when running a unit test in Visual Studio (2013).
System.IO.FileLoadException: Could not load file or assembly 'Newtonsoft.Json, Version=6.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
Newtonsoft.Json is a DLL that I referenced. But interestingly I referenced to Newtonsoft.Json 7.0 in all places. I was confused why reflection insisted loading an older version 6.0.
Any hint on where could I start to investigate?
Thanks,
I would check your web.config file to see if there is something that is referencing the old version.
You can also try this adding this in the web.config to ensure the correct version is used. I would put this in just after the <system.web> tag
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" />
<bindingRedirect oldVersion="0.0.0.0-7.0.0.0" newVersion="7.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
I have 2 assemblies lets call them A and B. I've assigned strong names to them and now the problem arises that assembly B is looking for the old version of assembly A.
**EDIT2: If I delete AssemblyB the problem persists so it might just be VS2008 looking for the old version? Also via fusionlog I see the following warning: wrn application configuration file binding redirects disallowed. Does this have anything to do with it? **
I get multiple errors of the same kind, here's one snippet:
You must add a reference to assembly 'AssemblyA, Version=1.2.4737.25316, Culture=neutral, PublicKeyToken=null'.
The strong named AssemblyA inside the project shows these properties:
Inside app.config I've placed this piece of code:
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="AssemblyA" culture="neutral"
publicKeyToken="a22e30ac6a0edfc0"/>
<bindingRedirect oldVersion="1.2.4737.25316" newVersion="1.3.0.19440"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
But this does not work. I have access to the source of both assemblies.
EDIT: If I delete the strong named and add the old (weak named) dll to the project it will give an error asking about the strong named version
You must add a reference to assembly 'AssemblyA, Version=1.3.0.19440, Culture=neutral, PublicKeyToken=a22e30ac6a0edfc0'.
What's happening here?
Some DLL's still referred to the old (weak named) version of other DLL's. Luckily the assemblies came with the source so I had to recompile everything including a key.
After that another error came up along the lines of "The located assembly's manifest definition does not match the assembly reference"
To fix this I added the following in the app.config.
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<publisherPolicy apply="no" />
<assemblyIdentity name="Assemblyname" culture="neutral" publicKeyToken="3a5628535d42dbed"/>
<bindingRedirect oldVersion="1.3.0.15233" newVersion="1.3.0.40647" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
I'm trying to add Elmah to my MVC3 project. After installing via Nuget, when I try to access elmah (via localhost:port/elmah.axd), I get an error containing this:
Could not load file or assembly 'MySql.Data, Version=6.1.3.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d' or one of its dependencies. The system cannot find the file specified.
I've removed the mysql.data dll and added my own copy (version 6.4.4.0 - the documentation says you can override the dll provided with a newer version), but this error remains. Has anyone else encountered this?
My solution was to add this to my web.config:
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity
name="MySql.Data"
publicKeyToken="c5687fc88969c44d"
culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.4.4.0" newVersion="6.4.4.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
This basically says to the compiler that whenever something requests a version of the MySql.Data assembly that's between versions 0.0.0.0 and 6.4.4.0, it should instead be supplied with the version 6.4.4.0 assembly instead.
I have created a publisher policy assembly following the post How to: Create a Publisher Policy. The policy redirects assemblies from the version 1.0.0.0 to the version 2.0.0.0.
This does work for me as long as the old assembly (v1.0.0.0) is located on the server (in the GAC). Is it possible to remove the old assembly version from the server?
The configuration I used:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Assembly.Name"
publicKeyToken="d24d3f23b4455982"
culture="neutral" />
<bindingRedirect oldVersion="1.0.0.0"
newVersion="2.0.0.0"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
Shame on me. I did a mess with the assembly versions. So the answer is: Yes, it works without the legacy assembly.