Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Could not load file or assembly or one of its dependencies

People also ask

Could not load file or assembly DLL or one of its dependencies?

There are some workarounds for this issue: The dll file may not be in /bin folder. Just copy the dll file to /bin folder or set this preference Copy Local = True from Visual Studio. If the problem persists, check if the version of the assembly that is referenced is different than the version it is looking for.

Can not load file or assembly?

In summary if you get the "Could not load file or assembly error", this means that either your projects or their references were built with a reference to a specific version of an assembly which is missing from your bin directory or GAC.

Could not load file or assembly the located assembly's manifest definition does not match the assembly reference?

The located assembly's manifest definition does not match the assembly reference. As stated, this is caused when the version of a . dll file in the /bin directory (assembly reference), is not the same as specified in the web. config (assembly manifest).


  1. Check if you are referencing an assembly which in turn referencing an old version of unity. For example let's say you have an assembly called ServiceLocator.dll which needs an old version of Unity assembly, now when you reference the ServiceLocator you should provide it with the old version of Unity, and that makes the problem.

  2. May be the output folder where all projects build their assemblies, has an old version of unity.

You can use FusLogVw to find out who is loading the old assemblies, just define a path for the log, and run your solution, then check (in FusLogvw) the first line where the Unity assembly is loaded, double click it and see the calling assembly, and here you go.


Open IIS Manager

Select Application Pools

then select the pool you are using

go to advanced settings (at right side)

Change the flag of Enable 32-bit application false to true.


For me, none of the other solutions worked (including the clean/rebuild strategy). I found another workaround solution which is to close and re-open Visual Studio.

I guess this forces Visual Studio to re-load the solution and all the projects, rechecking the dependencies in the process.


Try to clean Debug and Release folders in your solution. Then remove and add unity again.


At 99% the Could not load file or assembly or one of its dependencies problem is caused by dependencies! I suggest you follow this steps:

  1. Download Dependency Walker from http://www.dependencywalker.com/

  2. Launch Dependency Walker and open the dll (in my case NativeInterfaces.dll)

  3. You can see one or more dll with the error in red Error opening file...

  1. It means that this dll is missing in your system; in my case the dll name is MSVCR71.DLL

  2. You can download missings dll from google and copy in right path (in my case c:\windows\system32)

  3. At this point, you must register the new dll in the GAC (Global Assembly Cache): open a DOS terminal and write:

     cd \Windows\System32
     regsvr32 /i msvcr71.dll
    
  4. Restart your application