Error when running on .net Framework 4.0

Dec 3, 2011 at 7:35 PM
Edited Dec 3, 2011 at 7:47 PM

I downloaded the source code and built the 3 Autorun projects targeting the .net Framework 4.0 in VS2010. I created the HelloWorld project and added it to the Autorun solution. When I run the application in the debugger, I get the following error when I try to register the new HelloWorld.dll task (the dll doesn't show when I browse to it the its folder):

Error in IOAccessManagement::GetFiles(C:\Applications\Scheduler\Autorun\HelloWorld\HelloWorld\bin\Debug)

System.BadImageFormatException: Could not load file or assembly 'file:///C:\Applications\Scheduler\Autorun\HelloWorld\HelloWorld\bin\Debug\HelloWorld.dll' or one of its dependencies. This assembly is built by a runtime newer than the currently loaded runtime and cannot be loaded.

All 4 projects in the Autorun solution are targeted the .net Framework 4.0. I downloaded the source code in "C:\Applications\Autorun". Any idea? Thanks

Dec 5, 2011 at 8:43 AM


Here are some idea:

  • If working on Vista or 7, try to start VS2010 as administrator
  • Copy manually your HelloWorld.dll in the Autorun folder, and be sure you work with that DLL
    • When replacing the DLL: stop autorun before otherwise the old version is locked and remains into memory
  • Force the target CPU to X86 if not absolutely necessary to run in 64-bits

Hope this helps