Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Could not load file or assembly, PublicKeyToken=null

Could not load file or assembly 'NCrawler.GeckoProcessor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies.

When I call CrawlUsingGeckoProcessor.Run();

What does this mean? I can click "go to definition" and I can see the Run() method.

like image 297
senzacionale Avatar asked Oct 22 '11 12:10

senzacionale


People also ask

Why is PublicKeyToken null?

PublicKeyToken = null tells you that the CLR is looking for the unsigned assembly. Since you signed them, that's not going to work well and this kaboom is expected. You will have to rebuild the program so it uses the updated signed assembly and embeds the non-null PublicKeyToken into the manifest.

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 attempt was made to load a program with an incorrect format?

“An attempt was made to load a program with an incorrect format.” That means that the assembly, which was to be loaded, was in an unexpected format. The format, in this case, refers most likely to the 64-bit build of an application being deployed to IIS, which is being run in 32-bits.


2 Answers

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

If you still can't figure out which file fails loading, try using a tool such as Fusion Log Viewer (run fuslogvw.exe from the Visual Studio command prompt), to determine which files the CLR was trying to load and from where, so that you can see exactly what failed.

like image 128
Ran Avatar answered Sep 20 '22 05:09

Ran


I experienced the same problem, and the reason was that I compiled my EXE and DLL on 32 bit machine for "x86", because it depends on C++\CLI library compiled for Win32. Then I tried to use this library on 64 bit machine from 64 bit process. Obviously 64 bit process can't load 32 bit libraries, so I got this error, which does not really help to understand the problem.

So the reason could be that you try to use 32 bit library from 64 bit process.

like image 20
nogard Avatar answered Sep 18 '22 05:09

nogard