I have a given code written in unmanaged C++ that I added as a resource in a C# program.
When trying to load the unmanaged EXE using Assembly.Load
, I get a BadImageFormatException
whose InnerException says that "the IL Format is incorrect" (obviously).
How can I make this work?
I know that using the code as a DLL would be better, but for some reason, the dll call does not behave the same way as when I run the unmanaged exe with System.Diagnostics.Process.Start
.
And I don't want to have two separates EXE files. Any idea?
EDIT: OK, I no longer need to do that. My dll behaved a different way because I was using it in a different context (winform instead of console); therefore the function causing the problem, SetThreadDesktop
, couldn't work as expected. Gonna close post now, thanks for all those who answered.