Using .NET class from BMAX

BlitzMax Forums/BlitzMax Programming/Using .NET class from BMAX

JPL(Posted 2005) [#1]
Hi !

I've written a library in C# and I would like to call some functions of this library from BMAX (and ideally map my C# classes to BMAX classes).
Is it possible ? If so, how do I declare my functions or classes in C# to make them visible from BMAX ?

I've successfully called C# function from BMAX with a Bridge dll written in Managed C++, but it's pretty heavy and unefficient.
(To TeraBit : I've seen you already done this (at least call functions), and I like to have details about the method you've used if possible.)

Best Regards,
JPL


Perturbatio(Posted 2005) [#2]
he's posted source here: http://www.blitzbasic.com/Community/posts.php?topic=44412


JPL(Posted 2005) [#3]
Ok, I've downloaded the source before posting on the forum, but the package only contains the BMAX source (the caller) but not the C# source of the DLL.
I'd like to know how to define my functions and classes IN C# to export them and make them visible by BMAX.

Thanks,


Perturbatio(Posted 2005) [#4]
You'd probably be best emailing terabit, he doesn't seem to hang around here much these days.


TeraBit(Posted 2005) [#5]
Hi All,

Life has been pretty busy recently and I've had to shelve my personal programming projects for the moment.

It's simple enough to do the DLL. Simply make a class and use all static functions. You will then need to run another program to fix it into a standard DLL

The class for the DLL in my demo:



and a short BlitzPlus program to do the conversion of the DLL into a standard Blitzable DLL:



It's a bit rough around the edges, but it does the job.


JPL(Posted 2005) [#6]
Really good job Lee, Thanks a lot.


demonsource(Posted 2005) [#7]
terabit, this is a very practical solution

i like it, but it is not the way for me

i have explored another way, with some managed c++ and explicit/dynamic loading of libraries upon the windows platform

understanding why it works is arcane (ms proprietary)
but programmers who understand what they are using, why and how it works are cool (any kids around?)

by the way, my prototype was for purebasic, i did not recompile for bmx

i am not an expert at blitzmax but have enough brains to be an owner of this software

i have done some benchmarks of bmx against others (using the "framework" statement to limit and compare exe size) and am impressed