Reputation: 65
I am trying to create a webservice where the functions are performed by a 64 bit DLL. When I try to build this service i get the error "An attempt was made to load a program with an incorrect format." But when I run a 32 bit DLL it works fine.
I am trying to run in a visual studio 2012 on .net 4 framework in C#
I have tried changing the app pool settings in IIS and changed build platform target to any cpu. Cannot identify where the problem is coming from. Please provide you assistance. Thank you
Upvotes: 2
Views: 7170
Reputation: 19
Try not to mix AnyCPU compilation with 32 or 64 bit DLL (DLL can be compiled as 32bit or 64bit or both) - behavior will depend on platform and in some environments it will work, in some not.
Upvotes: 0
Reputation: 62532
Right click on the application pool you are using and go to Advanced Settings
. Under (General)
there is a setting called Enable 32-Bit Applications
. If you're running on a 64 bit OS and this is set to true
then the app-pool will be a 32bit process, and therefore your 64bit DLL won't load. Set it to false
to make your app-pool a 64bit process.
Also, check the dependencies of the DLL you're building as 64bit. It may be using a 32bit dll/assembly. If you've got any [DllImport]
attributes in your code then look at the .dlls they refer to and ensure they're 64bit compatible.
Upvotes: 2
Reputation: 114
If your web service references 64 bit dlls it must be compiled to x64
Upvotes: 0