Unmanaged DLL

B

Brian Scott

Hi,

Can someone help me out. I am trying to write a dynamic link library in
embedded visual C++ that will be called using DLLImport in CF.

The problem is that after succesfully building the dll I keep getting
System.MissingMethodException on the CF program. I build the library using
AMRV4 for the handheld and x86 for PPC2002 emulator.

I have checked the dependencies and maming with Depends.exe and also Dumpbin
and everything seems fine. I've tried EntryPoint as function and also
ordinal value but with the same error.

I am using Embedded Visual C++ 4.0 with both service packs as well as having
installed PPC2002 SDK on my machine.

I do however get the following message after each build as well as only
being able to target STANDARDSDK. Is there some configuration problem I have
missed?

"An appliaction targetting a Standard SDK for Windows CE .NET and built for
the X86 CPU cannot be run on the emulator device. In oder to run this
application on any CPU other thatn the Emulator, you will have to install an
SDK that is compatible with the Standard SDK for Windows CE.NET, then target
a shadow platform pertaining to that SDK."

Finally, I have tried sing extern "C" as well as a DEF file for exporting
the function names unmangled.

/****************************************
EVC++ Code;


#include "stdafx.h"

BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
return TRUE;
}


extern "C" _declspec(dllexport) int WINAPI Myadd(int a, int b)
{
return a+b;
}


extern "C" _declspec(dllexport) int WINAPI Mymulti(int a, int b)
{
return a*b;
}


/****************************************
C# CF code

[DllImport ("TestDll.dll")]
public static extern int Myadd(int i1, int i2);

[DllImport ("TestDll.dll")]
public static extern int Mymulti(int i1, int i2);

/****************************************
 
G

Geoff Schwab [MSFT]

A

Alex Feinman [MVP]

I don't believe you can build for PPC2002 using eVC 4. You need eVC3 for
that
 
G

Geoff Schwab [MSFT]

I should have mentioned that you can get rid of that message by setting your
build options. In the IDE menu in eVC 4.0 go to Tools->Options and select
the Download tab in the Options popup. Uncheck the "Always download binary
to the target" and "Always download dependencies to the target" properties.


--
Geoff Schwab
Program Manager
Excell Data Corporation
http://msdn.com/mobility
http://msdn.microsoft.com/mobility/prodtechinfo/devtools/netcf/FAQ/default.aspx

This posting is provided "AS IS" with no warranties, and confers no rights.
Geoff Schwab said:
The error about the configuration is not a problem as long as you build for
the correct architecture which it sounds like you did. Where are you
installing the DLL on the device and emulator? Try placing it in the
Windows directory if you are not already.

--
Geoff Schwab
Program Manager
Excell Data Corporation
http://msdn.com/mobility
http://msdn.microsoft.com/mobility/prodtechinfo/devtools/netcf/FAQ/default.aspx

This posting is provided "AS IS" with no warranties, and confers no rights.
Brian Scott said:
Hi,

Can someone help me out. I am trying to write a dynamic link library in
embedded visual C++ that will be called using DLLImport in CF.

The problem is that after succesfully building the dll I keep getting
System.MissingMethodException on the CF program. I build the library using
AMRV4 for the handheld and x86 for PPC2002 emulator.

I have checked the dependencies and maming with Depends.exe and also Dumpbin
and everything seems fine. I've tried EntryPoint as function and also
ordinal value but with the same error.

I am using Embedded Visual C++ 4.0 with both service packs as well as having
installed PPC2002 SDK on my machine.

I do however get the following message after each build as well as only
being able to target STANDARDSDK. Is there some configuration problem I have
missed?

"An appliaction targetting a Standard SDK for Windows CE .NET and built for
the X86 CPU cannot be run on the emulator device. In oder to run this
application on any CPU other thatn the Emulator, you will have to
install
an
SDK that is compatible with the Standard SDK for Windows CE.NET, then target
a shadow platform pertaining to that SDK."

Finally, I have tried sing extern "C" as well as a DEF file for exporting
the function names unmangled.

/****************************************
EVC++ Code;


#include "stdafx.h"

BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
return TRUE;
}


extern "C" _declspec(dllexport) int WINAPI Myadd(int a, int b)
{
return a+b;
}


extern "C" _declspec(dllexport) int WINAPI Mymulti(int a, int b)
{
return a*b;
}


/****************************************
C# CF code

[DllImport ("TestDll.dll")]
public static extern int Myadd(int i1, int i2);

[DllImport ("TestDll.dll")]
public static extern int Mymulti(int i1, int i2);

/****************************************
 

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