While debugging, I notice the following with this C# app I have here:
It appears to try to load all DLL files that happen to reside in the same directory as the executable. (Even ones that are completely unrelated to anything in this project/solution.)
The app is loading and working fine, however I find the debug output weird: (paths snipped)
...
A first chance exception of type 'System.BadImageFormatException' occurred in mscorlib.dll
'my_test.exe': Loaded '....\release\mfc42u.dll', Symbols loaded (source information stripped).
'my_test.exe': Unloaded '....\release\mfc42u.dll'
A first chance exception of type 'System.BadImageFormatException' occurred in mscorlib.dll
'my_test.exe': Loaded '....\release\mpiwin32.dll', Binary was not built with debug information.
'my_test.exe': Unloaded '....\release\mpiwin32.dll'
A first chance exception of type 'System.BadImageFormatException' occurred in mscorlib.dll
...
The two DLLs above have absolutely nothing to do with the C# project or anything it references. Why is the executable (or the VS debugger?) trying to load these DLLs?
Seems this app is actively loading these DLLs after all!
This code I found in a component I was not familiar with:
0xA3’s comment about catching the 1st chance exception got me on the right track!