Raised This Month: $ Target: $400
 0% 

Using a C# dll from a plugin


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Mentar
New Member
Join Date: Dec 2005
Old 12-17-2005 , 10:22   Using a C# dll from a plugin
Reply With Quote #1

Is this possible?

What i'm trying to do is make a c# class library which the vc++ plugin references.

The problem is, well, it aint working :p. It's not even recognising the class library exists let alone letting me declare instances of the class' in it.


My c++ isn't that good, i know enough to get by but i'd like to avoid it whenever possible. That's why i'm trying to set it up so most of the data management kind of code (Database access, logging, timing etc) is written in the c# class library and the only code i need to write in c++ is the code that accesses source and the code that uses the c# dll.


What i'm working on is a booking system. You can book the server through a website (it records your booking in a database) and the server checks this database every 30 minutes (bookings are made in 30 minute blocks) and if there is a booking for that period it locks the server and sets the password to one you picked when you booked the server.

It's a wee bit more complicated than that but you get the idea.

The c# part is all done, tested and works perfectly. I now need to get the vc++ part to just do the following with it:

When the plugin starts, Declare an instance of the BookingManager Class and call it's start method.
Handle some events that are raised by the BookingManager class

Can not get the darn thing to see it though. Is this because it's just not possible or am i forgetting something (like i said, my c++ is weak )
Mentar is offline
EKS
Veteran Member
Join Date: Mar 2004
Location: Norway
Old 12-17-2005 , 11:46  
Reply With Quote #2

I dont know suffient amount of c++ to do what your requesting. But im guessing it would be a advatage to post your c++ code here. So ppl can look at it.
EKS is offline
devicenull
Veteran Member
Join Date: Mar 2004
Location: CT
Old 12-17-2005 , 12:17  
Reply With Quote #3

Not directly.. everything in .net is bytecode, meaning it runs through a virtual machine in order to be actually executed (like java). The problem with this is you trying to call functions wont work, because the code is still in bytecode format. You have to find a way to precompile the bytecode into actual code. Of couse this means you can't have compatibility with linux.. unless you can track down a .net compiler.
__________________
Various bits of semi-useful code in a bunch of languages: http://code.devicenull.org/
devicenull is offline
Thraka
AlliedModders Donor
Join Date: Aug 2005
Old 12-17-2005 , 16:17  
Reply With Quote #4

Well I requested something like this in the plugin request forums like 5 months ago but no replies...

I have a friend who's made a .NET wrapper to the Torque 2D engine that exposes evwerything T2D does and allows you to transfer data back and forth between the engine (which is written in C++ for cross platform)

People who want .NET support will probobly know that it means isolating the other platforms, but it doesn't matter to them.
Thraka is offline
sslice
Senior Member
Join Date: Feb 2005
Location: Texas, USA
Old 12-17-2005 , 17:55  
Reply With Quote #5

I'd rather see someone add some kind of scripting support like python (no, I dont mean eventscripts).
__________________
sslice is offline
Mentar
New Member
Join Date: Dec 2005
Old 12-17-2005 , 20:22  
Reply With Quote #6

Alright , i think i've got it working.

few steps.

Go to:
Project >> Properties >> General
Change 'Use Managed Extensions' to Yes

add these
#using <mscorlib.dll>
#using <system.dll>

now i can get to all my c# classes like

BookingManager::ClsBookingManager* test;
test = new BookingManager::ClsBookingManager;



It's passed the 1st test, no errors on compile, i've got to try installing the plugin in my test server now and see if it'l run.
Mentar is offline
Mentar
New Member
Join Date: Dec 2005
Old 12-17-2005 , 21:09  
Reply With Quote #7

bugger

when i install and run the plugin i get "R602 - pure virtual function call"

seems kinda odd to me, since that occurs when i call new for the BookingManager class and to my knowledge, constructors arn't virtual functions ....
Mentar is offline
XAD
Senior Member
Join Date: Mar 2004
Location: Sweden
Old 01-01-2006 , 09:57   Re: Using a C# dll from a plugin
Reply With Quote #8

Quote:
Originally Posted by Mentar
What i'm working on is a booking system. You can book the server through a website (it records your booking in a database) and the server checks this database every 30 minutes (bookings are made in 30 minute blocks) and if there is a booking for that period it locks the server and sets the password to one you picked when you booked the server.
Hmm, haven't read this thread until now but why don't you just make/use an rcon-client script to login and change the settings and kicks everyone. This script would be runned every 30 min if the server should be changed. This would be a pretty future safe solution as it would work on all HL2-mods and without any plugins or any other modifications...

By using this approach you can also send messages such as "slot time end within 5 min warning"...

/X
XAD is offline
Ahrex
Junior Member
Join Date: Dec 2005
Location: Perth, Australia
Old 01-01-2006 , 10:12  
Reply With Quote #9

I have this exact thing with an rcon library I wrote in perl. PM me if you'd like a copy...
Ahrex is offline
Ahrex
Junior Member
Join Date: Dec 2005
Location: Perth, Australia
Old 01-01-2006 , 10:13  
Reply With Quote #10

Goddamn. Quote instead of edit...twice. It's late here...
Ahrex is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 04:24.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode