problem in using exported function in a native DLL

V

vijay

I'm having trouble with calling an exported function in a
native DLL compiled with eMbedded Visual C++ using C#.

Basicly, I have one exported function in the DLL:
whenever i execute this exe to Pocket pc it returns
MissingMethod Exception.

Code for DLL is
NativeFunctions.h

#ifdef NATIVEDLL_EXPORTS
#define DLLEXPORT _declspec(dllexport)
#else
#define DLLEXPORT _declspec(dllimport)
#endif
#ifdef __cplusplus
extern "C" {
#endif
DLLEXPORT int function();
#ifdef __cplusplus
}//end extern "C"
#endif
NativeFunction.cpp

#include "stdafx.h"
#include "NativeFunctions.h"
int function()
{
return 25;
}

and a C# client of the DLL:

using System;
using System.Data;
using System.Runtime.InteropServices;

namespace Client
{
class Class1
{
[ DllImport("NativeFunction.dll", EntryPoint="function") ]
public static extern int function();

static void Main(string[] args)
{
int x = function();
MessageBox.Show(x.toString());
}
}
}
 
M

Mattias Sjögren

Basicly, I have one exported function in the DLL:
whenever i execute this exe to Pocket pc it returns
MissingMethod Exception.

It's probably exported with a decorated (mangled) name. Try running

dumpbin /exports NativeFunction.dll

and see what the real exported name is.



Mattias
 

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