So I started working on an existing project at work in NopCommerence and I accidently added the Newtonsoft.Json DLL to the Nop.Core project, ever since then, the project keeps randomly crashing giving me the error:
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)
Could not load file or assembly 'Newtonsoft.Json, Version=4.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)
I removed the reference from the project right away, so there is now no reference to this DLL in the Nop.Core project.
But there is some code in the project which looks for the reference:
When we get to that plugin it crashes here:
I got no clue where to even look to solve this, it looks like it's trying to load two different versions of the DLL and when I Google around, it says to update though NuGet and I did this and nothing has solved it.
So you removed the reference, but what about the actual dll file? It looks like something is 'discovering' it at runtime and it exists on your disk somewhere and the application is finding it.
It's hard to know what to suggest but try to find out where the app is looking for plugin files, then look in that directory and delete the Json stuff. You could also try just deleting all of the bin and obj directories in the whole solution, since they will be re-created by the next build. Also look in the packages directory in the root of your solution, you may find a copy of the Json package lingering there. If you;ve definitely removed it using NuGet, then delete it from packages too.
Make a backup copy before you start, just in case my suggestions are complete rubbish ;-)
Related
I have the situation where I have a class library being used in a Unity3D project, and which uses Json serialization/deserialization. Since the official NewtonSoft.Json NuGet doesn't work well together with Unity, I am using Json.Net.Unity3D (v. 9.0.0.0), which has worked fine up until now.
Now I'm setting up another project, where one of the main component has a dependency on NewtonSoft.Json (v. 11.0.0.0). This new project also needs to reference the previously mentioned class library. This compiles without problem, but when the class library tries to use the Json functions, it can't find the needed Json library and I get an error.
System.IO.FileLoadException: Could not load file or assembly 'Newtonsoft.Json, Version=9.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)
File name: 'Newtonsoft.Json, Version=9.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' ---> System.IO.FileLoadException: Could not load file or assembly 'Newtonsoft.Json, Version=11.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)
File name: 'Newtonsoft.Json, Version=11.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed'
Since the two Json library versions have differing PublicKeyTokens, the binding redirect won't work. I've been trying unsuccessfully to find a solution to this problem, but would need some input. These are the possible options I've come up with:
Preventing the main project's Json library propagating to the
referenced project somehow. If I run a test version where the main
project doesn't have a Json library at all, the sub project works
fine.
Hacking the binding redirect to accept different dll:s for different versions. Doesn't seem to be possible.
Having both versions installed in the main project and used where appropriate. Also seems like a non-starter.
Any insight would be much appreciated - I've wasted way too much time on this problem already.
Here's a small test solution that demonstrates the problem
I'm not sure if this would work, but you could try to have the v9 referenced through nuget package, and the v11 referenced manually from dll file that will be "copy always" to output directory plus it should have different file name. This way the output assembly should load two json dlls - v9 and v11.
I ended up deciding that this was not possible with a reasonable amount of work, so I took another approach. I created an interface that provided the same methods from NewtonSoft.Json used by my library (i.e. JsonConvert.Serialize and Deserialize), and then made a wrapper implementing said interface in each project referencing the library. This allowed me to completely remove any references to NewtonSoft.Json from the library, and it only required a small amount of duplicated code in each project.
I have a Solution with many different project types in (Class File, ASP.net MVC 5, ASP.net Core 2.1). When I try and build the Solution I get this error:
Could not load file or assembly 'System.Web.Mvc, Version=5.2.4.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
However, there is no associated project name. Project, File, Line are all empty.
How can I find out which project is causing the error? How can I trouble shoot this?
I can find various Google results for the particular error - but if the compiler doesn't even tell me which project is at fault - how can I begin to fix it?
Thanks.
Update:
What are the valid reasons for the compiler not supplying the name of the project at fault, if any?
System.Web.Mvc is a namespace used by MVC 5 so the error is likely occurring in your MVC 5 project (https://learn.microsoft.com/en-us/previous-versions/aspnet/web-frameworks/dd492706(v=vs.118)).
One quick fix would be to ensure that the package is in your project. If you find that it's missing, generate a new project and copy over the binary from the bin directory of that project to your project.
Another thing you can try is deleting the reference to the package and adding it back. This should resolve any dependency issues regarding a version mismatch or file reference error.
After doing push from git server I got this error when I build and open my project:
Could not load file or assembly 'System.Web.Mvc, Version=5.2.3, Culture=neutral, PublicKeyToken=******' or one of its dependencies. The system cannot find the file specified.
The project is working pretty well with the same code in a different computer.
Problem
The error is a file not found, like the one I helped out with the other day:
Could not load file or assembly .. The system cannot find the file specified.
Troubleshooting
Open ProcessMonitor and run it when VS won't let you build your solution and throws the error. Stop the trace when it fails and investigate ProcMon's (Filemon) log to see where the IDE is looking for the DLL it cant find.
Solution
Put the DLL where its expected to be found (this will hopefully sort out the VS library referencing failure).
Also try:
disable Resharper
restart VS
clean & rebuild
I found nuget or some other update can bump the System.Web.MVC version to 4.0.0 unintentionally. So just check the dll that you have in your bin folder (or wherever the reference points) is of the same version specified in your web.config.
I took over a project recently and it's using the NopCommerence package. When I load up the package in Visual Studio, it works fine, I have no troubles in VS, when I push live, everything is fine too, all works, but as soon as a few days sometimes even hours have passed, I get this error message:
Could not load file or assembly 'NPOI, Version=2.0.6.0, Culture=neutral, PublicKeyToken=0df73ec7942b34e1' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
To solve this, I have to clean, rebuild and build the project and release a new set of files, my question is why does it randomly just fall over after so much time? I tried resetting the server, deleting temporary files but no luck.
Been doing this for weeks now and I can't find a solution.
This seems to be an issue where your .NET assembler is looking for an assembly of a specific version and instead of finding that, it is finding the assembly of that same thing, but of a different version.
It means that it wont work until both the files, i.e the actual file at the location and the reference in your configuration are same.
Check your config and then check on the actual file. If its of older or newer version, then replace it with the version that is actually required.
Here are a few links for your reference.
Assembly version mismatch
Resolving assembly conflicts
Hope this helps.
Im having some serous issues with a .dll not being found in Nop.Core.dll (i think)
the dll message the PluginManager.cs writes in the output in VS12 is as follows:
Could not load file or assembly 'Telerik.Web.Mvc, Version=2012.2.607.340, Culture=neutral, PublicKeyToken=29ac1a93ec063d92' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
Ive added the right version of Telerik.Web.Mvc to the Nop.Core lib and built a new .dll but the issue still remains.
Ive also checked for cached .dlls in th GAC but nothing.
The issue occured after a restart of VS12 so there´s smt weird going on here. Ive tried disabling/enabeling auto update nuget on build (as i thought that it might be fetching some new dlls that might create a conflict) but nothing.
I do see that the Solution is running .net 4.5 but the Telerik.Web.Mvc.dll target framework is :
TargetFramework(".NETFramework,Version=v4.0", FrameworkDisplayName=".NET Framework 4")].
Can this cause some dll´s to not find Telerik.Web.Mvc.dll?
As im new to nopCommerce im kinda lost at this point. What am i doing wrong here? =)
/seb
Edit:
Make sure you have non-corrupted Telerik.Web.Mvc.dll in your bin folder (download one that comes with nopcommerce and overwrite it to be sure)
This issue may be caused by a plugin that has wrong reference. If you have any custom/old plugins try removing them or readd their reference and recompile.
Current version in 3.10 is 2013.2.611.340 while you have reference to 2012.2.607.340