Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
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 Go to next message
nixnixnix is currently offline  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 #33348 is a reply to message #33346] Wed, 27 July 2011 07:26 Go to previous messageGo to next message
dolik.rce is currently offline  dolik.rce
Messages: 1789
Registered: August 2008
Location: Czech Republic
Ultimate Contributor

I'm not an expert on .net or windows programming, but I have a feeling that what you need is available in Koldos Functions4U package in bazaar.

Best regards,
Honza
Re: Linking to a .net DLL ? [message #33368 is a reply to message #33348] Thu, 28 July 2011 20:09 Go to previous messageGo to next message
nixnixnix is currently offline  nixnixnix
Messages: 415
Registered: February 2007
Location: Kelowna, British Columbia
Senior Member
Thanks Dolik and to you too, Koldo.

Exactly what I was looking for Smile

Nick
Re: Linking to a .net DLL ? [message #33370 is a reply to message #33368] Thu, 28 July 2011 23:12 Go to previous messageGo to next message
nixnixnix is currently offline  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 #33371 is a reply to message #33346] Fri, 29 July 2011 05:27 Go to previous messageGo to next message
Novo is currently offline  Novo
Messages: 1358
Registered: December 2006
Ultimate Contributor
Hi nixnixnix,
testFunc1 and testFunc2 most likely have C++ mangling.
I think you can get a list of exported function using either "VC\bin\dumpbin.exe" or dependency walker.

UPP has a nice feature called dli files.
You can find an example here: uppsrc\Oracle\Oci8.dli

I hope this will help.


Regards,
Novo

[Updated on: Fri, 29 July 2011 06:02]

Report message to a moderator

Re: Linking to a .net DLL ? [message #33398 is a reply to message #33371] Sun, 31 July 2011 23:37 Go to previous messageGo to next message
koldo is currently offline  koldo
Messages: 3356
Registered: August 2008
Senior Veteran
Hello Nick

In addition, I am not expert in .NET Dll but as Dl uses LoadLibrary function, it could only load .NET Dll plain not managed functions outside a class.


Best regards
IƱaki
Re: Linking to a .net DLL ? [message #33400 is a reply to message #33398] Mon, 01 August 2011 00:51 Go to previous message
nixnixnix is currently offline  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

Previous Topic: PrinterJob prints blank pages in linux
Next Topic: Getting compile errors, I modeled after TreeCtrlDnd, but I can't see the error
Goto Forum:
  


Current Time: Fri Apr 19 01:48:42 CEST 2024

Total time taken to generate the page: 0.04099 seconds