Gamestudio Links
Zorro Links
Newest Posts
Zorro 2.70
by jcl. 09/29/25 09:24
optimize global parameters SOLVED
by dBc. 09/27/25 17:07
ZorroGPT
by TipmyPip. 09/27/25 10:05
assetHistory one candle shift
by jcl. 09/21/25 11:36
Plugins update
by Grant. 09/17/25 16:28
AUM Magazine
Latest Screens
Rocker`s Revenge
Stug 3 Stormartillery
Iljuschin 2
Galactic Strike X
Who's Online Now
5 registered members (Dico, AndrewAMD, TipmyPip, NewbieZorro, Grant), 15,791 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
krishna, DrissB, James168, Ed_Love, xtns
19168 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
c# dlls in Lite-C? #279583
07/18/09 10:32
07/18/09 10:32
Joined: Jun 2004
Posts: 134
127.0.0.1
V
Vampir Offline OP
Member
Vampir  Offline OP
Member
V

Joined: Jun 2004
Posts: 134
127.0.0.1
Hi
Ich habe eine eigene, schnelle Netzwerkengine in C#
geschrieben.
Jetzt möchte ich die implementieren.

Aus Testzwecken habe ich erst eine ganz einfache dll geschrieben
mit folgendem Code:

Code:
using System;

namespace TestDll
{
    public class TestDll
    {
        public static int Calc(int i)
        {
            return (i * 2);
        }
    }
}



Danach habe ich das ganze in Lite-C versucht einzubinden:

Code:
#include <acknex.h>
#include <default.c>
#include <litec.h>
#include <com.h>

FONT* verdana_font = "Verdana#20";

var testvar = 0;

PANEL* testpan =
{
  digits(0,0,4,verdana_font,1,testvar);
  flags = VISIBLE;
}

int Calc(int i);

long h = LoadLibrary("TestDll.dll");
Calc = GetProcAddress(h,"Calc");

void main()
{
	video_mode = 12; // 1920x1200
	wait(1);
	
	while(1)
	{
		if(key_1)
		{
			while(key_1 == 1){wait(1);}
			testvar = Calc(5);
		}
		wait(1);
	}
}



Leider passiert einfach nichts, auch keine Fehlermeldung.
testvar bleibt 0. Aber das Lite-C Script ist sonst schon korrekt.
Die Dll liegt im gleichen Ordner wie das Script.

Hab schon früher Probleme gehabt und wende mich jetzt an euch grin

mfg
Vampir


My english is version 0.1 BETA. wow gamecard 4 president
Re: c# dlls in Lite-C? [Re: Vampir] #279628
07/18/09 14:09
07/18/09 14:09
Joined: May 2004
Posts: 1,510
Denmark
Claus_N Offline
Serious User
Claus_N  Offline
Serious User

Joined: May 2004
Posts: 1,510
Denmark
You should check this out if you want to use C# with Gamestudio smile
http://www.opserver.de/ubb7/ubbthreads.php?ubb=showflat&Number=277445#Post277445

It's possible to use COM-objects from Lite-C, but you can't (as far as I know) make COM-objects in C# - it's a .NET language (but I'm quite sure that you are aware of that wink ).

Last edited by Claus_N; 07/18/09 14:09. Reason: typo
Re: c# dlls in Lite-C? [Re: Claus_N] #279664
07/18/09 16:38
07/18/09 16:38
Joined: Jun 2004
Posts: 134
127.0.0.1
V
Vampir Offline OP
Member
Vampir  Offline OP
Member
V

Joined: Jun 2004
Posts: 134
127.0.0.1
That's very bad news 4 me.

I must search a solution to implement my network Engine in 3dgs.

The client side of the engine is small. I think I can write
the client part in C++ (dll) and the server side can rest in
C#.

The client side does only send and receive byte-arrays.
Encrypt and decrypt the packets.

Is that good idea? crazy

mfg
Vampir

PS: The network engine must have the power to handle many players. 3dgs <-> C++ <-> c# (can that be fast enought?)

Is the dll include Code above in lite-C right?
I fail when I use that DLL:

Code:
extern "C" __declspec(dllexport) int Calc(int * test);
  
int Calc(int * test){
return (test * 2);
}




My english is version 0.1 BETA. wow gamecard 4 president
Re: c# dlls in Lite-C? [Re: Vampir] #279672
07/18/09 17:31
07/18/09 17:31
Joined: May 2004
Posts: 1,510
Denmark
Claus_N Offline
Serious User
Claus_N  Offline
Serious User

Joined: May 2004
Posts: 1,510
Denmark
I'm afraid that I don't know about that, it's been a few years since I was toying with some dlls for 3DGS, so I don't recall how to use it.

Anyways, you should try asking in the 'Higher Languages' forum (or maybe even the Multiplayer forum), but I guess you already know that grin

Re: c# dlls in Lite-C? [Re: Claus_N] #279683
07/18/09 18:09
07/18/09 18:09
Joined: Aug 2005
Posts: 1,230
M
MichaelGale Offline
Serious User
MichaelGale  Offline
Serious User
M

Joined: Aug 2005
Posts: 1,230
You can host the .NET runtime in an unmanaged application and then load the managed library into it. However, since you are so eager to find a fast solution - rewriting it in C++ is the much better way to go. Hosting the .NET runtime will result in a performance and memory penalty.

However, if you want to take a look at the other solution, this article may be interesting for you. You can also try searching for keywords like "hosting .net runtime in an unmanaged application" or "loading a managed assembly in an unmanaged application", etc.


Your friendly mod is at your service.
Re: c# dlls in Lite-C? [Re: MichaelGale] #279687
07/18/09 18:29
07/18/09 18:29
Joined: Jun 2004
Posts: 134
127.0.0.1
V
Vampir Offline OP
Member
Vampir  Offline OP
Member
V

Joined: Jun 2004
Posts: 134
127.0.0.1
Ok, I see, it's better to rewrite the client in c++.

Do you think this can be a fast way?
3dgs Game Engine <-> c++ dll client <-> c# server

I think for the server: Good c# code is faster than bad c++ code.


My english is version 0.1 BETA. wow gamecard 4 president
Re: c# dlls in Lite-C? [Re: Vampir] #279691
07/18/09 18:50
07/18/09 18:50
Joined: Aug 2005
Posts: 1,230
M
MichaelGale Offline
Serious User
MichaelGale  Offline
Serious User
M

Joined: Aug 2005
Posts: 1,230
Depending on the speed of your every single component, it can either be faster or slower.


Your friendly mod is at your service.

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

Gamestudio download | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1