-
February 15th, 2011, 05:53 PM
#1
Accessing a windows DLL with interop
Hello Folks
I'm trying to access a regular windows 32 dll ( not a COM dll ) through .NET interop and I'm getting an exception EntryPointNotFoundException.
DLL was created using VS6. Following is the DLL code.
=================================================
#include "stdafx.h"
BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
return TRUE;
}
_declspec(dllexport) int Jumbo(int x)
{
return 11;
}
==================================================
Following is the .NET code (VS2008)
*********************************************************
using System.Runtime.InteropServices ;
public partial class Form1 : Form
{
[DllImport(@"C:\inprogress\CPP\TestDLL\Debug\TestDLL.DLL")]
public static extern int Jumbo(int x) ;
public Form1()
{
InitializeComponent();
}
private void cmdClick_Click(object sender, EventArgs e)
{
int y = Jumbo(1); ///This call throws exception
}
}
**************************************************
Now I tested the DLL with dll walker and I can see the exports. Also
I made another application using VC++ 6, and called the function in the DLL
successfully.
Could anyone tell me what is it I'm doing wrong?
thx
gulu.
-
February 15th, 2011, 05:59 PM
#2
Re: Accessing a windows DLL with interop
This was asked literally 4 days ago and is on the second page of this forum:
http://www.codeguru.com/forum/showthread.php?t=508635
-
February 16th, 2011, 12:38 PM
#3
Re: Accessing a windows DLL with interop
thank you BigEd. It gave me a clue. I need to declare the function
extern "C" _declspec(dllexport) int Jumbo(int x)
and it does the trick.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|