471,599 Members | 1,823 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,599 software developers and data experts.

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

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
Nov 17 '05 #1
1 1429
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 [Stinger]" <ma******************@stingergroup.net> wrote in message
news:Bu*********************@news4.tin.it...
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

Nov 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by Werner Partner | last post: by
8 posts views Thread by Noah Roberts | last post: by
reply views Thread by Ron | last post: by
1 post views Thread by Wilfried Mestdagh | last post: by
5 posts views Thread by Hardy Wang | last post: by
1 post views Thread by shapper | last post: by
2 posts views Thread by XIAOLAOHU | last post: by
reply views Thread by leo001 | last post: by
reply views Thread by Anwar ali | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.