I've spent hours trying to get this simple test case working, and searching the internet for clues.
I have a VS 10 solution containing my VB.net project, and a VC++ DLL project.
In my DLL project i have:
json_main.cpp:
#include <Windows.h>
extern "C"
{
void testMethod(int* inVal )
{
*inVal += 5;
}
}
JSON.def:
LIBRARY JSON
DESCRIPTION 'Simple JSON encoder/decoder'
EXPORTS
testMethod
And my VB.net code:
<DllImport("C:/inetpub/wwwroot/facebook/AlumniFinder/Debug/JSON.dll", CallingConvention:=CallingConvention.Cdecl)> _
Private Shared Sub testMethod(ByRef inVal As Integer)
End Sub
...
Dim var As Integer = 7
testMethod(var)
oLabel.Text = var.ToString
Yet when I try to run, I get the EntryPointNotFoundException
.
Anyone know what I might be doing wrong here? I tried开发者_如何学编程 using dumpbin.exe on my DLL, but I don't get any function names out of it to determine the mangling scheme it is using
Use dumpbin /exports
or Dependency Walker to check that you are exporting the function since it would seem that you are not.
My guess is that you didn't configure the build to pass the .def file to the linker. Do it like in this screenshot:
Try this (without the path, and with External
):
<DllImport("JSON.dll", CallingConvention:=CallingConvention.Cdecl)> _
Private Shared External Sub testMethod(ByRef inVal As Integer)
And make sure the JSON.dll is in the output directory (where the program is run from).
精彩评论