By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,088 Members | 1,512 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,088 IT Pros & Developers. It's quick & easy.

Problem in calling native DLL functions in C# in PocketPC 2002 environment

P: n/a
I'm having trouble with calling an exported function in a
native DLL compiled with eMbedded Visual C++ in C#
application in PocketPC 2002 OS.

Problem Description follows:
I have one exported function in the DLL:
I am making an application for pocket Pc in C# using this
DLL Function.
whenever I execute this exe in Pocket pc it returns
MissingMethod Exception.

Following is the listing of NativeFunctions.h,
NativeFunctions.cpp , NativeApp.cs files
Code listing for DLL is follows:

/***********************/
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;
}

******************/
C# client of the DLL follows:
/*********************************
NativeApp.cs
*****************/
using System;
using System.Data;
using System.Runtime.InteropServices;

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

static void Main(string[] args)
{
int x = function();
MessageBox.Show(x.toString());
}
}
}
/*****************************************/
Nov 15 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Hi Pawan,

You can check this link. I think it will be helpful:

http://groups.google.com/groups?hl=e...ame=right&th=2
bd0ecc8165653eb&seekm=012301c2c6ec%241db18570%24d2 f82ecf%40TK2MSFTNGXA09#lin
k9

Hope this helps.

Best Regards,
Lewis

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
| Content-Class: urn:content-classes:message
| From: "Pawan Aggarwal" <pa************@siemens.com>
| Sender: "Pawan Aggarwal" <pa************@siemens.com>
| Subject: Problem in calling native DLL functions in C# in PocketPC 2002
environment
| Date: Tue, 29 Jul 2003 23:54:33 -0700
| Lines: 67
| Message-ID: <09****************************@phx.gbl>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="iso-8859-1"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| X-MIMEOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
| Thread-Index: AcNWZ254EDkHdhHWSym4QfvVt2sAMg==
| Newsgroups: microsoft.public.dotnet.languages.csharp
| Path: cpmsftngxa06.phx.gbl
| Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.csharp:172886
| NNTP-Posting-Host: TK2MSFTNGXA11 10.40.1.163
| X-Tomcat-NG: microsoft.public.dotnet.languages.csharp
|
| I'm having trouble with calling an exported function in a
| native DLL compiled with eMbedded Visual C++ in C#
| application in PocketPC 2002 OS.
|
| Problem Description follows:
| I have one exported function in the DLL:
| I am making an application for pocket Pc in C# using this
| DLL Function.
| whenever I execute this exe in Pocket pc it returns
| MissingMethod Exception.
|
| Following is the listing of NativeFunctions.h,
| NativeFunctions.cpp , NativeApp.cs files
|
|
| Code listing for DLL is follows:
|
| /***********************/
| 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;
| }
|
| ******************/
| C# client of the DLL follows:
| /*********************************
| NativeApp.cs
| *****************/
| using System;
| using System.Data;
| using System.Runtime.InteropServices;
|
| namespace Client
| {
| class Class1
| {
| [ DllImport("NativeFunctions.dll", EntryPoint="function") ]
| public static extern int function();
|
| static void Main(string[] args)
| {
| int x = function();
| MessageBox.Show(x.toString());
| }
| }
| }
| /*****************************************/
|

Nov 15 '05 #2

P: n/a
Hi Pawan,

You can check this link. I think it will be helpful:

http://groups.google.com/groups?hl=e...ame=right&th=2
bd0ecc8165653eb&seekm=012301c2c6ec%241db18570%24d2 f82ecf%40TK2MSFTNGXA09#lin
k9

Hope this helps.

Best Regards,
Lewis

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
| Content-Class: urn:content-classes:message
| From: "Pawan Aggarwal" <pa************@siemens.com>
| Sender: "Pawan Aggarwal" <pa************@siemens.com>
| Subject: Problem in calling native DLL functions in C# in PocketPC 2002
environment
| Date: Tue, 29 Jul 2003 23:54:33 -0700
| Lines: 67
| Message-ID: <09****************************@phx.gbl>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="iso-8859-1"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| X-MIMEOLE: Produced By Microsoft MimeOLE V5.50.4910.0300
| Thread-Index: AcNWZ254EDkHdhHWSym4QfvVt2sAMg==
| Newsgroups: microsoft.public.dotnet.languages.csharp
| Path: cpmsftngxa06.phx.gbl
| Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.csharp:172886
| NNTP-Posting-Host: TK2MSFTNGXA11 10.40.1.163
| X-Tomcat-NG: microsoft.public.dotnet.languages.csharp
|
| I'm having trouble with calling an exported function in a
| native DLL compiled with eMbedded Visual C++ in C#
| application in PocketPC 2002 OS.
|
| Problem Description follows:
| I have one exported function in the DLL:
| I am making an application for pocket Pc in C# using this
| DLL Function.
| whenever I execute this exe in Pocket pc it returns
| MissingMethod Exception.
|
| Following is the listing of NativeFunctions.h,
| NativeFunctions.cpp , NativeApp.cs files
|
|
| Code listing for DLL is follows:
|
| /***********************/
| 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;
| }
|
| ******************/
| C# client of the DLL follows:
| /*********************************
| NativeApp.cs
| *****************/
| using System;
| using System.Data;
| using System.Runtime.InteropServices;
|
| namespace Client
| {
| class Class1
| {
| [ DllImport("NativeFunctions.dll", EntryPoint="function") ]
| public static extern int function();
|
| static void Main(string[] args)
| {
| int x = function();
| MessageBox.Show(x.toString());
| }
| }
| }
| /*****************************************/
|

Nov 15 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.