Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tips to help debug "Could not load file or assembly X or one of its dependencies"

I'm looking for tips/suggestions/insights to help debug an on application load issue; Could not load file or assembly...

The solution/project where I'm experiencing this issue is a conversion from a working copy in Visual Studio 2008 to the Visual Studio 2010 Release Candidate. The conversion process appeared to be successful, and all the solution projects are set to Framework 4.

The exception is on a 3rd party component (a graphics processing library), but any answers could possibly help others with any troublesome DLL.

Could not load file or assembly 'Aurigma.GraphicsMill.DLL' or one of its dependencies. is not a valid Win32 application. (Exception from HRESULT: 0x800700C1)

What's confusing about this exception is the additional text: is not a valid Win32 application.

The full exception stack trace is up on PasteBin, but doesn't seem to shed much more light on the issue...

What I have tried so far with no success:

  1. Simple clean, rebuild, restart combinations of Visual Studio 2010 RC.
  2. Removing and re-adding the DLL in question.
  3. Toggling "copy local" to true and false on the DLL in question.
  4. Confirming that after a "successful build" the DLL in question appears in the bin\debug folder.
  5. Checking for any unnecessary references to the DLL in question (none found).
  6. The associated licence file for the DLL in question is in the same directory with it.

I've also had no luck with it hitting any debugger breakpoints on application load.

like image 589
Nick Josevski Avatar asked Feb 15 '10 01:02

Nick Josevski


People also ask

How do you fix Could not load file or assembly 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.

Could not load file or assembly could not be found?

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 culture neutral Publickeytoken null or one of its dependencies?

This error usually means that the assembly was not found. Try verifying that the file exists in the directory where your application is running.


1 Answers

I have found the cause of this issue to be that because you have switched to .net v4, you are now using a new application pool in IIS7 specificially for asp.net v4 (the pool itself is called 'ASP.NET v4.0')

In the advanced settings section of the application pool, set 'Enable 32-bit Applications' to true and your problem DLL will now load as expected.

Obviously you should do the same if your web application has its own application pool.

If you are using Windows Server 2008 (not R2) see this post on how to assign correct permissions for your application pool identity

like image 186
Baldy Avatar answered Sep 18 '22 02:09

Baldy