Could not load file or assembly

First off, if you’re encountering this error, you may need to look farther than just here for a solution, especially regarding ASP.NET technology.

I spent a good 3 hours of my work-day scratching my head over how the hell I was going to fix this bug. First thought was to check my assembly references… well, everything checks out there… the program even runs properly in debug mode. The program even runs in damn release mode… but when I move the files to a new location, bam, I get the following error.

“Unhandled exception has occurred in your application…. Could not load file or assembly ‘xxx’ or one of its dependencies. The module was expected to contain an assembly manifest.”

Good god. What does it all mean? Well, before you jump to the assumption that

heh, stupid chump didn’t copy a file

.. I did, multiple times, after multiple rebuilds, cleans, rebuilds, cleans, changing on configuration settings etc. etc. etc. Turns out after the entire ordeal there was an extremely simple solution to the problem.

You see, the directory that I was copying my executable to also had a dll under the exact same name. bar.exe, bar.dll. This is a PROBLEM for my application.

The call structure that I created goes as so : foo.exe -> bar.exe. Extremely simple, done it a thousand times. But my application got the great idea to try and access bar.dll instead, thus creating a gigantic confusing problem that could have easily been avoided by using different assembly names. Oops.

After a quick rename of bar.dll, everything ran smooth as silk.

If you’re reading this and you have a similar problem, hopefully some light has been shed.

Until next time.

Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Connecting to %s