VERy strange error calling a C++ dll (CF, vs2003)

M

Marco [Stinger]

Hi
I'm writing a C# app with VS2003 for WinCE4 / 5 x86.
I must call some functions on a Embedded C++ Dll (I have the source
code of it).

The dll's Header is:
#ifdef INTERFACE_EXPORTS
#define INTERFACE_API __declspec(dllexport)
#else
#define INTERFACE_API __declspec(dllimport)
#endif


extern "C"
{
INTERFACE_API int PLCLoad(wchar_t*, int);
INTERFACE_API int PLCUnload(void);
INTERFACE_API int PLCInit(int,wchar_t*);
INTERFACE_API int PLCClose(int);
INTERFACE_API int PLCOpen(int,wchar_t*);
INTERFACE_API int PLCWrite(int,wchar_t*, int, WORD[]);
INTERFACE_API int PLCRead(int,wchar_t*, int, WORD[]);
INTERFACE_API wchar_t* PLCGetDescription(int);
INTERFACE_API int PLCGetLastError(int);
INTERFACE_API int PLCGetStatus(int);
INTERFACE_API int PLCGetVersion(int);
INTERFACE_API int PLCGetType(int);
}
----- END HEADER -----------

Here's the dumpbin.exe /EXPORTS:

Microsoft (R) COFF/PE Dumper Version 7.10.3077
Copyright (C) Microsoft Corporation. All rights reserved.


Dump of file c:\Progetti.net\SmartDeviceApplication1\Interface.dll

File Type: DLL

Section contains the following exports for Interface.dll

00000000 characteristics
4296C324 time date stamp Fri May 27 08:50:12 2005
0.00 version
1 ordinal base
12 number of functions
12 number of names

ordinal hint RVA name

1 0 0000100A PLCClose
2 1 0000103C PLCGetDescription
3 2 00001005 PLCGetLastError
4 3 0000101E PLCGetStatus
5 4 00001019 PLCGetType
6 5 00001037 PLCGetVersion
7 6 00001023 PLCInit
8 7 00001028 PLCLoad
9 8 00001014 PLCOpen
10 9 0000100F PLCRead
11 A 0000102D PLCUnload
12 B 00001041 PLCWrite

Summary

1000 .data
1000 .idata
1000 .rdata
1000 .reloc
2000 .text
------ END DUMPEXE ---------

And now my problem :

I write a test program, copy the dll in the same direcory as the .exe
and run it on the Emulator and a WinCE 5 x86 Device.

I call a dll function with the following code:

//[DllImport("interface.dll")]
[DllImport("interface.dll", CharSet=CharSet.Auto, EntryPoint="PLCLoad")]
extern static int PLCLoad(string DllName, int Vers);

int i = PLCLoad("Seriale.dll", 1);

And recive the following error:
"An unhandled exception of type 'System.MissingMethodException' occurred in
SmartDeviceApplication1.exe"

????? Can someone 'please tell me why ????????


Thanks in advance and have a nice WeekEnd
Marco
 
B

Brett

Possibly the interface.dll is trying to access another DLL and that is where
the error is coming from. Meaning, interface.dll is dependent on another
DLL. Try running depends exeName on your app to make sure you have all of
the needed DLLs. You probably have done this 10 times but make sure the
method name is correct. Inspect interface.dll for that.

Brett

Marco said:
Hi
I'm writing a C# app with VS2003 for WinCE4 / 5 x86.
I must call some functions on a Embedded C++ Dll (I have the source
code of it).

The dll's Header is:
#ifdef INTERFACE_EXPORTS
#define INTERFACE_API __declspec(dllexport)
#else
#define INTERFACE_API __declspec(dllimport)
#endif


extern "C"
{
INTERFACE_API int PLCLoad(wchar_t*, int);
INTERFACE_API int PLCUnload(void);
INTERFACE_API int PLCInit(int,wchar_t*);
INTERFACE_API int PLCClose(int);
INTERFACE_API int PLCOpen(int,wchar_t*);
INTERFACE_API int PLCWrite(int,wchar_t*, int, WORD[]);
INTERFACE_API int PLCRead(int,wchar_t*, int, WORD[]);
INTERFACE_API wchar_t* PLCGetDescription(int);
INTERFACE_API int PLCGetLastError(int);
INTERFACE_API int PLCGetStatus(int);
INTERFACE_API int PLCGetVersion(int);
INTERFACE_API int PLCGetType(int);
}
----- END HEADER -----------

Here's the dumpbin.exe /EXPORTS:

Microsoft (R) COFF/PE Dumper Version 7.10.3077
Copyright (C) Microsoft Corporation. All rights reserved.


Dump of file c:\Progetti.net\SmartDeviceApplication1\Interface.dll

File Type: DLL

Section contains the following exports for Interface.dll

00000000 characteristics
4296C324 time date stamp Fri May 27 08:50:12 2005
0.00 version
1 ordinal base
12 number of functions
12 number of names

ordinal hint RVA name

1 0 0000100A PLCClose
2 1 0000103C PLCGetDescription
3 2 00001005 PLCGetLastError
4 3 0000101E PLCGetStatus
5 4 00001019 PLCGetType
6 5 00001037 PLCGetVersion
7 6 00001023 PLCInit
8 7 00001028 PLCLoad
9 8 00001014 PLCOpen
10 9 0000100F PLCRead
11 A 0000102D PLCUnload
12 B 00001041 PLCWrite

Summary

1000 .data
1000 .idata
1000 .rdata
1000 .reloc
2000 .text
------ END DUMPEXE ---------

And now my problem :

I write a test program, copy the dll in the same direcory as the .exe
and run it on the Emulator and a WinCE 5 x86 Device.

I call a dll function with the following code:

//[DllImport("interface.dll")]
[DllImport("interface.dll", CharSet=CharSet.Auto, EntryPoint="PLCLoad")]
extern static int PLCLoad(string DllName, int Vers);

int i = PLCLoad("Seriale.dll", 1);

And recive the following error:
"An unhandled exception of type 'System.MissingMethodException' occurred
in
SmartDeviceApplication1.exe"

????? Can someone 'please tell me why ????????


Thanks in advance and have a nice WeekEnd
Marco
 

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