Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DLL Talk / making a dll?

Author
Message
wickedly kick it
17
Years of Service
User Offline
Joined: 13th Jul 2006
Location: Fort-worth Texas
Posted: 6th Aug 2009 06:45
Im fairly decent with c++ and i want to learn how to make a DLL, form what i understand is i pretty much just write out functions like:


and use it in dbp like this: a=addition(1,5)

Diggsey
17
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 6th Aug 2009 13:18
It's not nearly that simple

Open the DBPro help main page, and go to technical documents->third party commands. There is a tutorial there on how to make a plugin, but make sure you follow the tutorial exactly (especially the part on returning strings).

Also, Aaron Miller made this plugin SDK to make it even easier to make plugins

KISTech
16
Years of Service
User Offline
Joined: 8th Feb 2008
Location: Aloha, Oregon
Posted: 6th Aug 2009 22:00
It would be great if someone were to write up a tutorial or write a program that would convert VB.Net and C#.Net DLL projects to a TPC DLL. The threads I've found that had something going either ended in bickering or resulted in a program that's now out of date. It may work with the 2005 edition, but it doesn't work with 2008.



Phjon
18
Years of Service
User Offline
Joined: 28th Nov 2005
Location:
Posted: 6th Aug 2009 22:23
KISTech,

I've managed to create a .dll converter in VB.NET 2008 for this particular task using the_winch's C# code and references that came with his program, dll_tool, as a guide. I've been waiting for him to upgrade his program to work with the latest .NET version, but he hasn't done so at this time, so I'm having to work with the program that I've made to do the same job.

The trouble with it at the moment is, although it can sucessfully convert the dll's to make them DBPro-usable, I can't work out how to alter the resource strings to get the dll's to work as true TPC dlls - my fluency in C# is not all that brilliant.

Would it help if I posted a thread with the program I have constructed, and/or my program's VB code so that others might be able to create something which can actually do the above task?
KISTech
16
Years of Service
User Offline
Joined: 8th Feb 2008
Location: Aloha, Oregon
Posted: 6th Aug 2009 23:11
At this point anything would help. I've tried the_winch's program and it throws an error when I try and load my C#.Net 2008 class library. (DLL)

It says,

An unhandled exception has occured in your application. If you click continue the application will ignore this error and attempt to continue., etc...

Then if you click on details, the meat of the error is,

If I click continue it doesn't seem to load/find anything in the DLL I made.

Phjon
18
Years of Service
User Offline
Joined: 28th Nov 2005
Location:
Posted: 6th Aug 2009 23:23 Edited at: 6th Aug 2009 23:29
KISTech,

I got that error (or something similar) when I tried it with one of my VB dlls, hence why I made my own converter.

As you have the dll_tool, you must surely have the C# source code? As you seem to be fluent to some extent in C#, you could try to load the source code in your C# editor, correct the faults within the code, and compile and use the resultant program.

Where I think the problem may lie is that the program is not finding the ildasm.exe program. There is a drop-down menu, but you can't set it to use the latest ildasm.exe version.

If one was able to write a function that could take in a string parameter of the directory where the ildasm.exe (and the ilasm.exe) is located as a parameter, one could simply make a section within the program to allow the user to be able to set where the ildasm and ilasm exe's were located, and remove the drop-down features entirely.
KISTech
16
Years of Service
User Offline
Joined: 8th Feb 2008
Location: Aloha, Oregon
Posted: 6th Aug 2009 23:49 Edited at: 6th Aug 2009 23:52
That could be the problem, and is most likely.

I wouldn't say I'm fluent in C# by any means, but I've dabbled. It's not unlike most of the languages I've learned over the years, it's just a bit more picky than most.

I'll give it a shot and let you know if I get anywhere.

[edit]
I changed the dropdown box to the version of the .Net SDK that I have installed and I didn't get the error this time. I'm installing the SDK for the other version it shows now, and if I'm not mistaken C# 2008 Express requires version 3.5, so I may as well install that too.

KISTech
16
Years of Service
User Offline
Joined: 8th Feb 2008
Location: Aloha, Oregon
Posted: 7th Aug 2009 01:30 Edited at: 7th Aug 2009 06:55
[previous contents deleted]

Success!!

I downloaded and installed the .Net Framework 2.0 SDK and I was able to use DLL_Tool to convert a simple C#.Net 2008 DLL to a fully functional TPC DLL.

I'll be doing a few things with the code, and making sure I have everything where it should be, and I'll post a tutorial with full examples.



Phjon
18
Years of Service
User Offline
Joined: 28th Nov 2005
Location:
Posted: 7th Aug 2009 13:43
KISTech,

Good work!

Did you manage to get the dll_tool to convert dlls created with .NET 3.5, as that is the latest version of the .NET Framework?
KISTech
16
Years of Service
User Offline
Joined: 8th Feb 2008
Location: Aloha, Oregon
Posted: 7th Aug 2009 19:54
Yes. It's a C#.Net class library that says it requires 3.5. I don't know if that's going to cause some problems down the road if the 2.0 tools run into something it doesn't understand from the 3.5 framework, but for now it's working.

The test I ran was fairly basic, not quite as basic as adding two variables together, but complex enough that I think we're headed in the right direction.

the_winch
21
Years of Service
User Offline
Joined: 1st Feb 2003
Location: Oxford, UK
Posted: 8th Aug 2009 22:33 Edited at: 8th Aug 2009 23:27
dll_tool gets the location of ildasm.exe from the the values of "sdkInstallRootv1.1" and "sdkInstallRootv2.0" from the registry under "HKLMSOFTWAREMicrosoft.NETFramework".

Unfortunately dll_tool doesn't actually check if these values actually exists in the registry. If they don't exist you get an entry in the combo box that points nowhere. Then you get the "The system cannot find the file specified" since dll_tool tries to run an exe that does not exist.

The contents of the fixed tool.cs

I've attached a exe with the bug fixed. [now deleted, get the latest version from my website]

I only have the .net 3.5 runtime installed and I can't see a .net 3.5 ilasm. Perhaps 3.5 just uses the 2.0 ilasm/ildasm.
If anybody can provide a method to find ilasm/ildasm for .net 3.5 I will add it in but can't say if dll_tool will actually work with the new tools.

By way of demonstration, he emitted a batlike squeak that was indeed bothersome.
Phjon
18
Years of Service
User Offline
Joined: 28th Nov 2005
Location:
Posted: 8th Aug 2009 22:42 Edited at: 8th Aug 2009 22:52
the_winch,

Unfortunately, this program version won't work at all - it can't seem to find ildasm.exe (I have ildasm.exe on my PC, but dll_tool can't seem to find it all the same).

You could replace your drop-down menus with a system that allows the user to set where the ildasm/ilasm exes are manually (i.e. via an "OpenFileDialog" system).

Your program should work in theory with the present versions of ildasm.exe and ilasm.exe, as I managed to create a "half-way-house" program that can convert .NET dlls, but it cannot modify the resource strings (due to a lack of knowledge on my part on how to do this sucessfully).
the_winch
21
Years of Service
User Offline
Joined: 1st Feb 2003
Location: Oxford, UK
Posted: 8th Aug 2009 23:34 Edited at: 8th Aug 2009 23:37
I've added a custom item to the comboboxes. When selected it will ask for ilasm/ildasm via an open file dialog when building or opening a dll. It will only ask once then keep using the same value until the program is restarted.

http://winch.pinkbile.com/download/dll_tool.zip

I don't really use dbpro or .net any more so I am unlikely to do any more work on it.
Plus I think the idea is a bit of a dead end. dll_tool at least can be unreliable once the dlls start to get complex. Plus you still really need to know how dbpro and TPC dlls interact (especially for returning strings) so using .net doesn't really end up any simpler than using C/C++. There have also been developments with dbpro like the ability for a TPC dll to signal to the compiler what other dlls it depends on. I don't know how that will work with a .net dll.

Perhaps someone with more time/talent than me could create a more reliable and foolproof method that hides all the complexities.

By way of demonstration, he emitted a batlike squeak that was indeed bothersome.
Phjon
18
Years of Service
User Offline
Joined: 28th Nov 2005
Location:
Posted: 8th Aug 2009 23:50
the_winch,

Thanks for the help.

However, although I can now load my dll, it doesn't seem to like re-building it using the ilasm.exe. I'll run a couple more tests to see if I can get it to work.

If not, I may have to take another look at how I can fix my own program to add in the resource strings.

Login to post a reply

Server time is: 2024-03-29 15:17:21
Your offset time is: 2024-03-29 15:17:21