Problem in DllImport

W

wc

I'm trying to develop a window from application on C#, which require some
funtions from a COM DLL. So, I import the dll by using
System.Runtime.Interopservices.DllImport like this,

[DllImport("C:\\Program Files
(x86)\\ZIOSOFT\\Ziostation\\bin\\AxZpalKicker.dll")]
unsafe public static extern bool CheckZpal(byte * isrunning);

However, I'm getting a System.BadImageFormatException (HRESULT: 0x8007000B)
when trying to call CheckZpal() in one of the method...
The function declaration for CheckZpal in the COM interface is
STDMETHOD() IZpalKicker::CheckZpal ( BYTE * exist );

Can anyone advice what is the problem here? and how to fix it?

Regards,
/wc
 
F

Family Tree Mike

wc said:
I'm trying to develop a window from application on C#, which require some
funtions from a COM DLL. So, I import the dll by using
System.Runtime.Interopservices.DllImport like this,

[DllImport("C:\\Program Files
(x86)\\ZIOSOFT\\Ziostation\\bin\\AxZpalKicker.dll")]
unsafe public static extern bool CheckZpal(byte * isrunning);

However, I'm getting a System.BadImageFormatException (HRESULT:
0x8007000B)
when trying to call CheckZpal() in one of the method...
The function declaration for CheckZpal in the COM interface is
STDMETHOD() IZpalKicker::CheckZpal ( BYTE * exist );

Can anyone advice what is the problem here? and how to fix it?

Regards,
/wc


That error message usually means you are mixing 64 bit with 32 bit pieces.
The path to your dll seems to indicate it is 32 bit on a 64 bit OS machine.
Try building in 32 bit mode.
 
C

Charles Calvert

I'm trying to develop a window from application on C#, which require some
funtions from a COM DLL. So, I import the dll by using
System.Runtime.Interopservices.DllImport like this,

Why not register the COM DLL (if it's not already registered), then
add a reference to it and let the wizard generate the Interop classes
for you?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top