I have a situation where Docusign API is referencing the RestSharp signed assembly with a public key token of 598062e77f915f75. In the same project I am using the Twilio API which also references the unsigned Restsharp assembly, obviously with a null public key token.
I can make one or the other work but not both at the same time since I can't add both the signed and unsigned RestSharp references since they both have the same name.
When I have a reference to the signed assembly, the Docusign part works but the Twilio code errors with this:
Could not load file or assembly 'RestSharp, Version=105.2.3.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
When I reference the unsigned assembly, Docusign errors with this:
Could not load file or assembly 'RestSharp, Version=100.0.0.0, Culture=neutral, PublicKeyToken=598062e77f915f75' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
Is there any way around this?
I have tried binding redirects in every combination I can think of:
<dependentAssembly>
<assemblyIdentity name="RestSharp" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-100.0.0.0" newVersion="105.2.3.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="RestSharp" publicKeyToken="598062e77f915f75" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-100.0.0.0" newVersion="105.2.3.0" />
</dependentAssembly>
I can think of few possible ways to solve this issue:
Binding redirect. Works if assemblies have same public key, otherwise you need to specify code base. See SO answer: Referencing 2 different versions of log4net in the same solution
Using GAC. Not sure if it would work with unsigned assembly.
Making use of AppDomain.AssemblyResolve event (see How to use Assembly Binding Redirection to ignore revision and build numbers)
Signing / unsigning assembly with one key using ildasm.
I once had similar issue with different log4net versions being referenced by our project and 3rd party library. Here is a blog post.
I was facing the same issue. I have used the Nuget package of RestSharpSigned. This resolved my issue.
Try to redirect every version up to the current to the latest installed version:
<dependentAssembly>
<assemblyIdentity name="RestSharp" publicKeyToken="598062e77f915f75" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-105.2.3.0" newVersion="105.2.3.0" />
</dependentAssembly>
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 application running on a windows server 2012 that was using Telerik.Web.UI.dll version 2014.1.403.45.
During the latest deployment the Telerik dll under /bin folder got updated with 2015.1.401.40.
Because of new dll some functionality stopped working.
When i replace the dll on server with older version i get following error
Parser Error Message: Could not load file or assembly 'Telerik.Web.UI, Version=2015.1.401.40, Culture=neutral, PublicKeyToken=121fae78165ba3d4' or one of its dependencies.
The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
I also tried to assembly binding
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="Telerik.Web.UI" publicKeyToken="121fae78165ba3d4" culture="neutral"/>
<bindingRedirect oldVersion="2015.1.401.40" newVersion="2014.1.403.45"/>
<assemblyIdentity name="Microsoft.WindowsAzure.Storage" publicKeyToken="31bf3856ad364e35" culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-2.1.0.4" newVersion="2.1.0.4"/>
</dependentAssembly>
</assemblyBinding>
I am still getiing the same error.
Is there any way to handle this without deplying the entire code again?
i got this type of issue, but in different case(in Unit Testing). for that I cleared the Bin. then did a build. then issue resolved for me.
Maybe there is a way, but I would redeploy. Build it again with the reference to the older version. That's the safest way and the best way to make sure all references point to the same assembly.
To be absolutely sure about the right references, set the dll to copy to local is true, and copy and replace it with the one on your server.
My application creates multiple AppDomains and I manually configure the binding redirects via the SetConfigurationBytes method. I grab the config file, check for all assemblies installed on the private folder and then set the assemblyRedirect as on the example below. This is to ensure that I'll always use the shipped version of a given assembly:
<dependentAssembly>
<assemblyIdentity name="System.Net.Http" culture="neutral" publicKeyToken="b03f5f7f11d50a3a" />
<bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="2.2.18.0" />
</dependentAssembly>
However, when an assembly being loaded in a different AppDomain depends upon the System.Net.Http assembly, I get the following error: System.IO.FileLoadException: Loading this assembly would produce a different grant set from other instances.
There's two possible ways I've saw to solving this: either by removing the <dependentAssembly> element on the config for this DLL, or to add this assembly on the GAC.
I didn't like any of this because the first may cause problems with other assemblies and the second relies on the GAC, which some of my clients don't like.
Anyone have a different idea on how to solve this?
Thanks in advance.
I had telerik version 2012.2.607.35 When I update it to version 2015.2.623.45
I got this error:
Could not load file or assembly 'Telerik.Web.UI,
Version=2012.2.607.35, Culture=neutral, PublicKey
Token=121fae78165ba3d4' or one of its dependencies. The located
assembly's manifest definition does not match the assembly reference.
(Exception from HRESULT: 0x80131040)
I replaced all reference telerik to version 2015.2.623.45 in project references but the error exist yet.
While the assembly binding redirect is a way to solve this, as suggested by the answer, I would advise you to find the fully qualified assembly reference and make it non-fully qualified. It is likely to be a Register directive in the web.config or in a user control. Doing that will make future updates easier, otherwise you will get the same error the next time you upgrade unless you also update the bindingRedirect.
you should define assembly in web.config file
<dependentAssembly>
<assemblyIdentity name="YourDllFile" publicKeyToken="2780ccd10d57b246" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-YourDllFileVersion" newVersion="YourDllFileVersion" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="Telerik.Web.UI" publicKeyToken="121fae78165ba3d4" />
<bindingRedirect oldVersion="1.0.0.0-2015.2.600.45" newVersion="2015.2.623.45" />
</dependentAssembly>
I had a similar problem. I checked the version of the .dll in the bin folder on my website and the version throwing the error. Since the code where the error was being thrown was not my own, I realised the version of the .dll was a dependency of 3rd party code. As it turns out the .dll in my bin had been overwritten with an older version.
Solution was to put the correct version of the .dll in the bin folder (since this was installed with the application initially) seems an update failed to install the newer version.
I need to run two versions of same Dll to be run on my website simultaneously. So i have created a folder inside Bin and shown the second Dll path like this
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="AWSSDK" culture="neutral" publicKeyToken="9f476d3089b52be3"/>
<codeBase version="2.3.40.0" href="FILE://E://Live /bin/V-2/AWSSDK.dll"/>
</dependentAssembly>
</assemblyBinding>
and added my first dll as ordinary inside bin folder. But when I try to access any function inside my AWSSDK 2.3 Dll it throws an error like this
"Could not load file or assembly 'AWSSDK, Version=2.3.41.0, Culture=neutral, PublicKeyToken=9f476d3089b52be3' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)":"AWSSDK, Version=2.3.41.0, Culture=neutral, PublicKeyToken=9f476d3089b52be3"
Can anyone please point out what I am doing wrong here?
This error is because may be you have different versions of ddl but there namespace will be same, and you can reference only distinct namespaces in your project.
To overcome this,
Either create different namespaces for both versions or
use strong names for assemblies.