VERY strange error calling external DLL from C#

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
 
M

Marco [Stinger]

???? register ?????

Must I ?
It's no COM dll, it's just a brunch of functions... plus I've got an
Embedded C++ Test program that call (and uses) it correctly.

Besides......how do I register the dll ?

Thanks a lot

Ciao
Marco

Darren Shaffer said:
did you register the DLL on your device?
--
Darren Shaffer
.NET Compact Framework MVP
Principal Architect
Connected Innovation
www.connectedinnovation.com

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
 
P

Peter Foot [MVP]

Does a file with the same name exist anywhere else on the system, e.g.
\Windows?

Peter

--
Peter Foot
Windows Embedded MVP
http://www.inthehand.com | http://www.peterfoot.net |
http://www.opennetcf.org

Marco said:
???? register ?????

Must I ?
It's no COM dll, it's just a brunch of functions... plus I've got an
Embedded C++ Test program that call (and uses) it correctly.

Besides......how do I register the dll ?

Thanks a lot

Ciao
Marco

Darren Shaffer said:
did you register the DLL on your device?
--
Darren Shaffer
.NET Compact Framework MVP
Principal Architect
Connected Innovation
www.connectedinnovation.com

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
 
M

Marco [Stinger]

Surely not.
I've tried copying the Interface.dll to the root and to \Windows
but NO results !!

thanks for the help


Peter Foot said:
Does a file with the same name exist anywhere else on the system, e.g.
\Windows?

Peter

--
Peter Foot
Windows Embedded MVP
http://www.inthehand.com | http://www.peterfoot.net |
http://www.opennetcf.org

Marco said:
???? register ?????

Must I ?
It's no COM dll, it's just a brunch of functions... plus I've got an
Embedded C++ Test program that call (and uses) it correctly.

Besides......how do I register the dll ?

Thanks a lot

Ciao
Marco

Darren Shaffer said:
did you register the DLL on your device?
--
Darren Shaffer
.NET Compact Framework MVP
Principal Architect
Connected Innovation
www.connectedinnovation.com

message 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
 
A

Alex Yakhnin

Make sure that your native dll is compiled for the right processor type.

--
Alex Yakhnin, .NET CF MVP
www.intelliprog.com
www.opennetcf.org

Marco said:
Surely not.
I've tried copying the Interface.dll to the root and to \Windows
but NO results !!

thanks for the help


Peter Foot said:
Does a file with the same name exist anywhere else on the system, e.g.
\Windows?

Peter

--
Peter Foot
Windows Embedded MVP
http://www.inthehand.com | http://www.peterfoot.net |
http://www.opennetcf.org

Marco said:
???? register ?????

Must I ?
It's no COM dll, it's just a brunch of functions... plus I've got an
Embedded C++ Test program that call (and uses) it correctly.

Besides......how do I register the dll ?

Thanks a lot

Ciao
Marco

"Darren Shaffer" <[email protected]> ha scritto
nel messaggio did you register the DLL on your device?
--
Darren Shaffer
.NET Compact Framework MVP
Principal Architect
Connected Innovation
www.connectedinnovation.com

message 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