dominicwong
asked on
Mysterious exception "BadImageFormatException" from an un-used DLL in C# project
Hi experts
My C# project imports an external DLL generated by C code. But after I'd removed all references to the DLL in my C# project. I am still getting this exception:
"BadImageFormatException" that complaint about a dll: "Could not load file or assembly file .... TestLib.dll or in one of its dependencies. The module was expected to contain an assembly manifest."
But my program had already removed all references to the DLL.
I'd done a Clean and Rebuilt Solution.
I'd rebooted my PC.
I'd manually deleted all the files in the bin/Debug folder (except the DLL file)
My question is where does the program remember looking for the DLL while I'd already removed it from everywhere I could think of.
Eventually to get rid of the exception, I need to remove the DLL from the folder. But it shouldn't be the case.
Also, my PC is 32-bit Windows XP. So why I am getting this exception that normally happens when 32-bit meets 64-bit??
Thanks in advance.
My C# project imports an external DLL generated by C code. But after I'd removed all references to the DLL in my C# project. I am still getting this exception:
"BadImageFormatException" that complaint about a dll: "Could not load file or assembly file .... TestLib.dll or in one of its dependencies. The module was expected to contain an assembly manifest."
But my program had already removed all references to the DLL.
I'd done a Clean and Rebuilt Solution.
I'd rebooted my PC.
I'd manually deleted all the files in the bin/Debug folder (except the DLL file)
My question is where does the program remember looking for the DLL while I'd already removed it from everywhere I could think of.
Eventually to get rid of the exception, I need to remove the DLL from the folder. But it shouldn't be the case.
Also, my PC is 32-bit Windows XP. So why I am getting this exception that normally happens when 32-bit meets 64-bit??
Thanks in advance.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks again. Very much appreciated!!
ASKER
That was exactly where my problem was. In some part of my code, I was using reflection to load the assemblies:
Open in new window
Now I did as per your illustration and everything works fine. :)