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 / Has anyone made a dll using visual studio 2005 c#/c++??

Author
Message
Hummanoid Typhoon
18
Years of Service
User Offline
Joined: 4th Aug 2005
Location: Middle of nowhere
Posted: 18th Jun 2007 22:46
I have made a test dll in both c# and c++ but can't call my function.

here is my code

DB code


c# Code


c++ code



It would be fantastic if I could get the string table thing working but as far as i can see vs2005 does not produce the decorated names found in older versions.

thanks for any help

IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 18th Jun 2007 22:58
Quote: "Has anyone made a dll using visual studio 2005 c#/c++"

Not that I'm aware of, but there have been vb.net ones, and c# isn't all that different.

Quote: "as far as i can see vs2005 does not produce the decorated names found in older versions"

It does for plain C++ names - you're using the CLR for your example code and I don't know how that handles name collisions.

You're also using a class - DBPro doesn't know classes. You need to use a plain function instead:


I don't believe that there's anything to stop you using the CLR in your code, but if you do, you will need to access it via a plain function.

Hummanoid Typhoon
18
Years of Service
User Offline
Joined: 4th Aug 2005
Location: Middle of nowhere
Posted: 18th Jun 2007 23:45 Edited at: 18th Jun 2007 23:47
Thanks Ian thats very helpful

I was struggling to get c++ to compile without keeping the classes in there. Didn't think it was possible!

Anyway i got the function to call and multiply the numbers for me.

I would love to use c# because i'm more at home with it's syntax but from what I can see it's impossible to use c# dll's because you can't do anything outside of a namespace or class. Or if you can those bits of documentation are eluding me. I will look into the vb methods and see if i can glean any info from how that was done.

Can't find any way of makeing string tables in vs2005 express either. I think they have crippled that ability, but i can survive with calling the dll.

CattleRustler
Retired Moderator
20
Years of Service
User Offline
Joined: 8th Aug 2003
Location: case modding at overclock.net
Posted: 19th Jun 2007 00:52 Edited at: 19th Jun 2007 00:53
Ive written plenty of plugins in VB.NET, but the dll needs to be "converted" to then be used directly in dbp, like if it was a c++ dll/plugin. I use a cool tool written by ZKAT8IT which does all of the conversion, string table building, and dll recompiling automatically, no muss-no fuss. It works with C# and some other environments too (managed c++ iirc, but dont quote me)

You can search around the forums for ZK's thread and links to his site if youre interested

"In the event that I am reincarnated, I would like to return as a deadly virus, in order to contribute something to solve overpopulation" Prince Philip 1988
Hummanoid Typhoon
18
Years of Service
User Offline
Joined: 4th Aug 2005
Location: Middle of nowhere
Posted: 19th Jun 2007 01:10 Edited at: 19th Jun 2007 01:14
I have just been reading his threads it looks really good. Sadly none of the download links work and his site seems to be gone??! I found another exporter but it didn't work.

EDIT Just found his new site with google

Raven
19
Years of Service
User Offline
Joined: 23rd Mar 2005
Location: Hertfordshire, England
Posted: 19th Jun 2007 10:12
C#



Although this can be a hit'n'miss given DBP only supports cdecl, whereas PInvoke uses stdcall. You're best bet realistically is to make it a class then use C++ .NET to create an interface to DBP.

MSDN2 has all the information you'd need on the subject.
Failing that, realistically .. just make it all in Native C++ and include managed where-ever it's absolutely necessary. Without understanding the COM Interop and PInvoke it is very difficult to get .NET to talk to non-CLR, although possible using unsafe and static pointers (references)

The method above should work for the CallDll command, but it won't work with direct function linking (i.e. TPC DLLs); DBP just can't handle that sort of interaction. Also while I've shown you how to export the function statically to interop with COM and Native code, unsafe is turned off by default (can't turn it on in Express iirc) and you have to program with pointers for any io data which in C# is far trickier to do than C++ as you have to write many classes/types/structs from scratch.

Hummanoid Typhoon
18
Years of Service
User Offline
Joined: 4th Aug 2005
Location: Middle of nowhere
Posted: 19th Jun 2007 14:24 Edited at: 19th Jun 2007 14:26
ahh I see it's looking like c++ is my best bet although i like c# tricky pointers do not sound like a productive method of working. Do yo happen to know if the express edition limits creation of string tables?

Can't find the option anywhere but i do have it working with the call dll command now.

I may just get blue GUI but my plan is to make a custom menu as a plugin. I will eventually have to make a network plugin for my project so wanted to learn a bit while i'm making the editor.

jinzai
17
Years of Service
User Offline
Joined: 19th Aug 2006
Location: USA
Posted: 19th Jun 2007 15:39 Edited at: 19th Jun 2007 15:55
String tables are easy enough to cobble up yourself. They are contained in the projects' .rc file, and they look like any other resource:



You add a string resource, and then you add its resource ID in resource.h

Zerk
18
Years of Service
User Offline
Joined: 13th May 2006
Location: Orbiting Jupiter
Posted: 10th Aug 2007 18:27
My plugin is made in VS2005 C++.

Get zParticle! An advanced particle system plugin for DBP!
Website and Download link!

Login to post a reply

Server time is: 2024-05-22 19:30:23
Your offset time is: 2024-05-22 19:30:23