简体   繁体   中英

Can't start 32-bit DLL in VS2015

I have an issue with VS2015.

I want to create a DLL that reads through .csv file, and for this, I'll use the Jet ADO Provider, but it only works in 32-bits.

Therefore, I am trying to execute a 32-bit DLL on my 64 bit windows 7.

I have created a Class Library Project, with an empty UserControl. No external reference, no code whatsoever.

If I run in "Any CPU" or "x64", everything works fine. If I set the target CPU to "x86", it won't lauch, with error

An unhandled exception of type 'System.BadImageFormatException' occurred in mscorlib.dll

In the console, I can read:

'UserControlTestContainer.exe' (CLR v4.0.30319: DefaultDomain): Loaded 'C:\Windows\Microsoft.Net\assembly\GAC_64\mscorlib\v4.0_4.0.0.0__b77a5c561934e089\mscorlib.dll'. Skipped loading symbols. Module is optimized and the debugger option 'Just My Code' is enabled.

It seems to indicate that mscorlib.dll is loaded from a 64-bit folder, although I am in 32-bit, and I haven't found where to change this.

Could you please help me fix this?

Regards, Maxime

Thanks to the comments on the question, I managed to get it to work:

  • In VS2015, it is possible to run a Class Library without .exe project.
  • When a Class Library is run without a .exe project, an ad-hoc project is created, with standard configuration: "UserControlTestContainer.exe". On a 64-bit system, it is executed as a 64-bit application.
  • In order to execute a 32-bit DLL, a user-made exe project, set up to 32-bit is needed.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM