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>
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 have a simple c# application and I would like to reference an assembly from C:\..\..myassembly.dll without copying the thing to bin folder.
I there a way to change how is assembly being referenced/loaded?
Edit: the assembly is not in gac
Actually it is possible during runtime by using <codeBase> tag in your configuration:
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="MyAssembly2" culture="neutral" publicKeyToken="307041694a995978"/>
<codeBase version="1.0.1524.23149" href="FILE://C:/Myassemblies/MyAssembly2.dll"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
You can refer to the MSDN to get more specific info. The downside of this solution is that you have to manually specify assembly version.
Multiple solutions to your problem.
To avoid copying library to output folder set Copy Local to false by selecting .dll property.
Option 1:
Include below section in your configuration file and let allow runtime to load from location you specified.
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="MyAssembly" publicKeyToken="2d65620afb84f19d" />
<codeBase version="1.0.0.0" href="C:\..\..myassembly.dll" />
</dependentAssembly>
</assemblyBinding>
</runtime>
Option 2:
Well known option, use reflection to load your assembly.
Assembly.Load(#"C:\..\..myassembly.dll")
Hope this helps !
In my project I have to use different versions of AWSSDK dll's, in order to make this i took help of this post . and added one of my dll in to a folder named V-1 inside bin folder. Then made config changes like this
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="AWSSDK" publicKeyToken="CD2D24CD2BACE800" culture="neutral" />
<codeBase version="1.4.8.2" href="V-1\AWSSDK.dll" />
<codeBase version="2.3.40.0" href="AWSSDK.dll" />
</dependentAssembly>
</assemblyBinding>
</runtime>
But I still gets the error like this
Error 2 Could not load file or assembly 'AWSSDK, Version=1.4.8.2, Culture=neutral, PublicKeyToken=cd2d24cd2bace800' or one of its dependencies. The system cannot find the file specified. E:\Live \Web.config 129
At this line in web-Config
<add assembly="AWSSDK, Version=1.4.8.2, Culture=neutral, PublicKeyToken=CD2D24CD2BACE800" />
Can anyone please point-out what I am doing wrong??
Please open Solution Explorer in visual studio
Open References under the project
Select AWSSdk reference and go to its properties.
Set Specific Version = True and Copy Local = False
Make sure your output directory does not contain this dll in it.
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).
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.