When trying to run my project/website I get the error message:
Could not load file or assembly 'System.Web.Helpers, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.
I don't know where the System.Web.Helpers is coming from it is not even referenced in my solution. I did a find all for System.Web.Helpers and on 3.0.0.0 and it found neither. Also this project is working for other people on my team on the same branch.
I've looked around the internet and tried a lot of the solutions. Running out of ideas.
For myself, I had to remove all <dependentAssembly> references to the DLLs being complained about from:
<configuration>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
Once removed this issue was fixed. I also ensured MVC 3 and MVC 4 were installed via the Web Platform Installer
Related
I have an ASP.NET web project that has been running for years. Last year we changed one of the data sources to MYSQL so added MySqlConnector from NuGet. Just recently the application started throwing the error "Could not load file or assembly 'System.Diagnostics.DiagnosticSource, Version=6.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference." This error only occurs when we try to connect to MySql using MySqlConnetor. All NuGet packages have been updated and using .NET framework 4.6.1. The assembly binding portion of the webconfig is;
<assemblyIdentity name="System.Diagnostics.DiagnosticSource" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-7.0.0.0" newVersion="7.0.0.0" />
</dependentAssembly>
Similar questions have been ask in this forum and I have tried all suggested solutions, but am still getting the error. This must have been caused by an OS update as the error started occurring on the live server as well as my development machine.
We are getting an assembly conflict after we updated Newtonsoft.Json. I am having trouble understanding where the specific version that is referenced in the error is coming from. There is nothing in the web.config that points to a specific version.
System.IO.FileLoadException: Could not load file or assembly
'Newtonsoft.Json, Version=3.5.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)
Would GAC-ing the two versions of the assembly work to solve the issue?
As #jammykam commented in marto's answer you can redirect the assembly. I have done this in the past with Newtonsoft and Sitecore without a problem. You can take a look at my Sitecore Content as Service code where I have it working.
You are specifically interested in these lines in the web.config file:
https://github.com/HedgehogDevelopment/sitecore-content-service/blob/master/Sitecore/Web/Web.config#L3499
<dependentAssembly>
<assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.8.0" newVersion="4.5.0.0" />
</dependentAssembly>
GACing them might work but it will create a maintenance nightmare. Don't do it!
I think you have 2 options:
Use the version that came with Sitecore which will depend on which version of Sitecore you are running.
Leave the one sitecore version untouched and use ilmerge to combine the Newtonsoft.Json version you need with your own assembly.
I would recommend 1 if you don't need any of the most recent features of the library like (dynamics... etc)
MainApp/bin
There are some custom dlls here:
MainApp/bin/Custom_Dlls
I've added a probing as below to the web.config file located under the MainApp:
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<probing privatePath="bin;bin\Custom_Dlls" />
</assemblyBinding>
</runtime>
When I run my .aspx web page whose dll is under Custom_Dlls folder, it shows me an error message that the "Could not load type ..." which means it can't find the dll.
System.Web.HttpParseException (0x80004005): Could not load type <AssemblyName>.WebForm1'.
I've also tried using the full physical path "file:///C:\MainApp\bin\Custom_Dlls" but doesn't work.
Any help? anything else I'd need to do?
Thanks,
You can sign your assembly and deploy it to GAC. This will do the job for you.
Alternative is to load assembly at runtime. Take a look at my post for loading plugins:
VB.NET dynamic plugin components
I am having a problem where an older GAC'd assembly is being used instead of a newer version assembly in the bin.
Server:
Assembly version: ASP.NET MVC 3 RC 1 (3.0.11029.0)
Full name: System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
Code base: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Web.Mvc/v4.0_3.0.0.0__31bf3856ad364e35/System.Web.Mvc.dll
Deployment: GAC-deployed
Development machine:
Assembly version: Unknown version (3.0.20105.0)
Full name: System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
Code base: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Web.Mvc/v4.0_3.0.0.0__31bf3856ad364e35/System.Web.Mvc.dll
Deployment: GAC-deployed
The newer RTM version (3.0.20105.0) is in the bin directory of the application. However, the application is using the one in the GAC instead of the local bin. My experience from windows applications is the local bin deployed DLL always takes precedence because the GAC is checked only if the DLL isn't found in the same directory as the application. This convention appears to not be the case for a web application.
How can I force it to use my newer version bin deployed DLL (3.0.20105.0)?
Edit:
I actually did try a binding redirect like so:
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="3.0.11029.0" newVersion="3.0.20105.0" />
I tried several variations on the oldversion such as 0.0.0.0-4.0.0.0. In all my attempts usually it either loaded the older version, or gave me this exception message:
Could not load file or assembly 'System.Web.Mvc' or one of its dependencies.
The located assembly's manifest definition does not match the assembly reference.
The binding log didn't have any errors except this was last two lines:
WRN: Comparing the assembly name resulted in the mismatch: Build Number
ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.
Answered is SO Dll in both the bin and the gac, which one gets used? Note, you must run strong name hijack or it will use the GAC version.
I would retag this, it is not MVC specific.
You can modify your .config files to use assembly binding redirection for this and force the runtime to load different versions as you require.
This exception is not showing when debugging locally and shows up only when i browse to the remote url address of the server..
I have FTP'd the MVC 3 app to my remote server and a check of the Bin folder there shows that I have all three MySQL reference assemblies. All are version 6.4.4.0.
In my web.config file all of the version numbers relating to those are set to version 6.4.4.0.
Why am I getting this error message about version 6.3.6.0, and how can this be solved?
Could not load file or assembly 'MySql.Data, Version=6.3.6.0,culture=neutral, PublicKeyToken=c5687fc88969c44d' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
Exception Details: System.IO.FileLoadException: Could not load file or assembly 'MySql.Data, Version=6.3.6.0, Culture=neutral, PublicKeyToken=c5687fc88969c44d' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
There are a lot of things to check with this, but the most common one I've run accross was resolved by making sure the assembly is referenced correctly in the Visual Studio project and that the information is correct in the web.config.
In Visual Studio, check the properties on the references for the assemblies
verify the the version listed.
check if Specific Version is true/false.
check if Copy Local is true.
If the version is wrong, you may have to remove and re-add the reference.
I would guess the exception was not thrown on your local machine because the older version of the assemblies are available on your machine.
The reason your local information is showing in the exception is unrelated to the assembly reference issue. Your local system is where the assembly was built, and so that information is built in for debugging purposes. (If this exception was thrown while you were debugging, VS would bring you to that line of that file.)
Ok I was worried that I somewhere along the way bits of 6.3.6.0 where left on my system from when I had it installed.. After days of trying to figure this one out I actually have come up with the fix for this issue... I just simply needed to overwrite the version information using assembly binding in the web.config. Once I did that it loads from the remote server error free... Here is what I added to my web.config:
<dependentAssembly>
<assemblyIdentity name="MySql.Data" publicKeyToken="c5687fc88969c44d" />
<bindingRedirect oldVersion="0.0.0.0-6.3.6.0" newVersion="6.4.4.0" />
</dependentAssembly>
Could you please explain where I put the "Copy local = true" I do not see it as being part of any property window. I did find "Always Copy" for the resources. also where does this go in the web.config
<dependentAssembly>
<assemblyIdentity name="MySql.Data" publicKeyToken="c5687fc88969c44d" />
<bindingRedirect oldVersion="0.0.0.0-6.3.6.0" newVersion="6.4.4.0" />
</dependentAssembly>
I ran the package manager console and then used this to fix this problem:
PM> Install-Package MySQL.Data.Entities