Could Not Load File or Assembly or One of Its Dependencies

Could not load file or assembly or one of its dependencies

  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.

Error : Could not load file or assembly or one of it's dependencies

Yeah...!!! I found a solution for this terrible error...
First of all Thanks for every one who tried to help me... Here's my solution...

  1. Right Click on the Solution name
  2. Click Clean Solution
  3. Restart Visual Studio
  4. Goto project Properties >> Build
  5. Change Configuration to Release
  6. Start Debugging (F5)

1) , 2)

Right Click on the Solution name

4) , 5)

Change Configuration to Release

Next time keep in mind to keep a recent backup of your project folder.

Could not load file or assembly or one of its dependencies

Reason for that error is: the said assembly Microsoft.Owin.Security.OAuth is locked by some other process. Means, at current some other process already using it and your application is trying to load the same.

Most probably you application is already running and you are trying to build your solution. solution: End your application and then close and re-open your solution again.

Could not load file or assembly '' or one of its dependencies

Problem Solved!

I thought that Visual Studio was copying the DLL in to the GAC, but apparently not. So I copied it there manually and it works.

One question though, is this normal that visual studio does not copy it to the GAC when I deploy the sharepoint application?

For those who would like to know how to copy the dll to GAC

there are two ways to copy the dll to GAC:

  1. copy the dll manually

    1. Open c:\windows\assembly directory in windows explorer
    2. Open another instance of windows explorer and go to the place where your dll is located,
      usually in the bin folder. (so now you will have two windows open)
    3. select the dll you would like to copy to gac and drag it inside the assembly directory, c:\windows\assembly
  2. use VS to deploy it for you to GAC.

    1. in your sharepoint project double click on "Package".
    2. Package.Package will open. Look bottom left of your screen and click on "Advanced",
    3. then click on "Add", then select "Add Assembly from project output...".
    4. In the Source project dropdownlist select the project and then click OK.
    5. finally deploy the solution and the dll will be in the GAC.

thank you for your support.

Could not load file or assembly or one of its dependencies. Access is denied

Issue was caused by laptop encryption software. It encrypts all files downloaded. IIS didn't know how to un-encrypt it.

Could not load file or assembly, or one of its dependencies

The solution: rename AnimmexAPI-AnyCPU.dll to AnimmexAPI.dll and include it again to your solution.
The explanation is actually given in this answer: Loading renamed C# assembly throws FileNotFoundException

Could not load file or assembly ... An attempt was made to load a program with an incorrect format (System.BadImageFormatException)

I am pretty sure you're having a 32-bit / 64-bit conflict. It sounds like your main project might be set to 32-bit while the class its referencing is set to 64-bit. Try looking at this SO question and this one too. Between the two of them, you should be able to figure out your problem.

Could not load file or assembly or one of its dependencies. Access is denied. The issue is random, but after it happens once, it continues

My solution is as follows:

I didn't find a root folder under C:\Windows\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files.

Google told me that it might be a permission issue against current user, then I found I have a current Identity: IIS APPPOOL in the malfunctioning server where the rest of the server has Current Identity: NT AUTHORITY\NETWORK SERVICE.

Then I changed Current Identity from IIS APPPOOL to NT AUTHORITY\NETWORK SERVICE.

From here, I found that resetting the web app rebuilds the temporary ASP.NET cache, solving the issue.

Visual Studio 2019 Error - Could not load file or assembly or one of its dependencies

thank you for your solutions but I found the problem:

The project solution has some projects with .net standard 2.0 and some with .net framework 4.8. Somehow, when I run the app, some packages are not loaded correctly and it throws an error.

That line below solved my problem:

<RestoreProjectStyle>PackageReference</RestoreProjectStyle>

Put it in all .net framework 4.8 projects on first XML tag.

Thank your for all.

Regards.



Related Topics



Leave a reply



Submit