Try to re-Compiling and re-run all script code this is due an attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B) if this is still encountered then try to set or enable to 32 bit.
Because my web service application was using an older 32-bit driver, and or you can try using IIS7 to run in 32-bit mode and this is how I did it.
Under IIS7, my web application was running in an application pool.
Right clicked over the AppPool name
1.Selected Advanced Settings...
2.Under the General Section, set Enable 32-Bits Application to True
3.Click OK, you may want to recycle the application pool just to be sure.
All men by nature desire knowledge.
Aristotle (384 BC - 322 BC), Metaphysics
msrnivas
Member
428 Points
125 Posts
LoadLibrary throwing error HRESULT: 0x8007000B
Oct 11, 2011 07:07 PM|LINK
Hi
When i tried to load c++ library(dll) from asp.net 3.5 getting below error
An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)
but when i run my project from visual studio(by pressing F5) i could run dll without any error.
When i run my project from IIS its throwing above error.
What could be the problem?
my code
[
DllImport("kernel32.dll")]
static extern IntPtr LoadLibrary(string lpFileName);
DllImport("kernel32.dll")]
public static extern IntPtr FreeLibrary(IntPtr library);
DllImport("C:\\Inetpub\\wwwroot\\test\\bin\\myAPI.dll", EntryPoint = "GetXML", SetLastError = false, CharSet = CharSet.Ansi)]
private static extern void GetXML(StringBuilder myString, int length, int id);
string DLLPath = "C:\\Inetpub\\wwwroot\\test\\bin\\myAPI.dll";// System.Configuration.ConfigurationManager.AppSettings["componentpath"];
IntPtr lib = LoadLibrary(DLLPath); //
string resultxml = string.Empty;
StringBuilder str = new StringBuilder(10000);
GetXML(str, str.Capacity, 250);
string myString = str.ToString();
FreeLibrary(lib);
Mamba Dai - ...
All-Star
23531 Points
2683 Posts
Microsoft
Re: LoadLibrary throwing error HRESULT: 0x8007000B
Oct 13, 2011 09:14 AM|LINK
Hi,
This error indicates that you are trying to load a 32 bit dll into a 64 bit process.
The both post below have disccussed a this issue, please check:
http://social.msdn.microsoft.com/Forums/en-US/netfx64bit/thread/35b09f74-1d8e-4676-90e3-c73a439bf632/
http://social.msdn.microsoft.com/Forums/en/netfxsetup/thread/3da8eceb-0f8f-4d2b-9ea0-0b25defd997d
Feedback to us
Develop and promote your apps in Windows Store
jendim
Member
111 Points
33 Posts
Re: LoadLibrary throwing error HRESULT: 0x8007000B
Oct 13, 2011 09:26 AM|LINK
Hi!
Try to re-Compiling and re-run all script code this is due an attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B) if this is still encountered then try to set or enable to 32 bit.
Because my web service application was using an older 32-bit driver, and or you can try using IIS7 to run in 32-bit mode and this is how I did it.
Under IIS7, my web application was running in an application pool.
Right clicked over the AppPool name
1.Selected Advanced Settings...
2.Under the General Section, set Enable 32-Bits Application to True
3.Click OK, you may want to recycle the application pool just to be sure.
Aristotle (384 BC - 322 BC), Metaphysics
mkonanki
Contributor
2820 Points
624 Posts
Re: LoadLibrary throwing error HRESULT: 0x8007000B
Oct 13, 2011 09:34 AM|LINK
HRESULT show that this is most likely a 64bit vs 32bit issue.
1. check the dll is which bit
2.The other option is to change your application pool for the website to use 64bit. (I believe 32-bit is default).
check below thread for iis7 configure 32-bit
http://forums.iis.net/t/1171453.aspx