|
-
August 6th, 2014, 05:05 AM
#1
Calling a DLL written in VC++.NET Native Code from a VB.NET project
I have just installed VC++.net (2010 Express version) on a Win XP machine (the reason I am still using XP is that I need to use VB6 for a while and it will not install on Win 7/8). I would install 2013 VC++.net but it is only available for Win 7/8
So, i have built a small test dll and am trying to call it from a project written in vb.net, as follows:
In VC++
Code:
extern "C" {
__declspec(dllexport) double TestF();
}
__declspec(dllexport) double TestF(){
double ax = 0;
ax = 999;
return ax;
}
In vb.net
Code:
Public Declare Function TestF Lib "C:\....\mopeks.dll" () As Double
dblX = TestF()
This works and it returns "999" as hoped for. The problem is that when I include a parameter so that we have:
__declspec(dllexport) double TestF(double dblValue){ etc etc
I get PInvoke problems, namely:
"PInvokeStackImbalance was detected
Message: A call to PInvoke function 'MOPEKS!MOPEKS.prjDLLs::TestF' has unbalanced the stack. This is likely because the managed PInvoke signature does not match the unmanaged target signature. Check that the calling convention and parameters of the PInvoke signature match the target unmanaged signature."
I suspect I need to use "_stdcall" or whatever? Any guidance much appreciated
Last edited by wavering; August 6th, 2014 at 05:07 AM.
MOPEKS - a freeware program that generates programs that use each other to solve problems. Is this the correct route to a genuinely intelligent machine?
Tags for this Thread
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
|