|
|
Home » U++ Library support » U++ Library : Other (not classified elsewhere) » Linking to a .net DLL ?
Linking to a .net DLL ? [message #33346] |
Tue, 26 July 2011 22:43 |
nixnixnix
Messages: 415 Registered: February 2007 Location: Kelowna, British Columbia
|
Senior Member |
|
|
Can't find anything on this when I search these fora.
I would like to be able to use some functionality which is proprietary and only available as .net
My colleague can get what I want to compile into a DLL but I am wondering how I then can use that DLL in UPP.
Cheers,
Nick
|
|
|
|
|
Re: Linking to a .net DLL ? [message #33370 is a reply to message #33368] |
Thu, 28 July 2011 23:12 |
nixnixnix
Messages: 415 Registered: February 2007 Location: Kelowna, British Columbia
|
Senior Member |
|
|
Hey Koldo,
Should this work for a .NET compiled DLL? I am trying the following
AgiRadar::AgiRadar()
{
// connecting to .net DLL to use the following functions
// Public Shared Function testFunc1() As Integer
// Return 123
// End Function
// Public Shared Function testFunc2(ByVal x As Double) As Double
// Return x * x
// End Function
Dl turbineSpeedCalc;
String myDllFolder = "D:\\temp\\test\\Debug\\";
/////////////////////////////////////////
double (*testFunc2)(double);
if (!turbineSpeedCalc.Load(AppendFileName(myDllFolder, "turbineSpeedCalc.dll")))
throw Exc(Format(t_("% dll not found"), "turbineSpeedCalc"));
testFunc2 = (double (*)(double))turbineSpeedCalc.GetFunction("testFunc2");
if (!testFunc2)
throw Exc(Format(t_("Function %s was not found in dll"), "testFunc2"));
double argOut = testFunc2(15.0);
String s = Format("answer is %f",argOut);
PromptOK(s);
//////////////////////////////////////////
int (*testFunc1)();
if (!turbineSpeedCalc.Load(AppendFileName(myDllFolder, "turbineSpeedCalc.dll")))
throw Exc(Format(t_("% dll not found"), "turbineSpeedCalc"));
testFunc1 = (int (*)())turbineSpeedCalc.GetFunction("testFunc1");
if (!testFunc1)
throw Exc(Format(t_("Function %s was not found in dll"), "testFunc1"));
double argOut2 = testFunc1();
s = Format("answer is %f",argOut2);
PromptOK(s);
}
is there a way to list the functions available in a DLL? I figure if I can get these simple functions to work then I should be able to pass structs and arrays to real functions.
It successfully finds and loads the DLL but fails to find either function.
Cheers,
Nick
[Updated on: Thu, 28 July 2011 23:14] Report message to a moderator
|
|
|
|
|
Re: Linking to a .net DLL ? [message #33400 is a reply to message #33398] |
Mon, 01 August 2011 00:51 |
nixnixnix
Messages: 415 Registered: February 2007 Location: Kelowna, British Columbia
|
Senior Member |
|
|
Thanks.
Dependency walker does not see any functions in the DLL so am thinking there is something that my colleague has neglected to do that is akin to publishing the functions. I have never used DLLs before so am not really sure what am talking about. He is on vacation just now so I will have to ask him when he gets back.
Cheers,
Nick
EDIT: so I just tried linking into the DLL with MS VC++ express and a piece of code from http://support.microsoft.com/kb/953836
With some small adjustment I can trigger the function turbineSpeedCalc::testFunc1. The main difference appears to be that Functions4U allows me to access only global functions within the DLL whereas I appear to need access to a class. If I can make an instance of the class that is within the DLL then I should be able to access its functions.
[Updated on: Mon, 01 August 2011 04:08] Report message to a moderator
|
|
|
Goto Forum:
Current Time: Wed Apr 24 15:48:20 CEST 2024
Total time taken to generate the page: 0.02772 seconds
|
|
|