how to use a C# dll like a C dll

how to use a C# dll like a C dll

am 29.10.2007 23:52:29 von Relaxin

I want to create some DLL's in C# but they must be used in a C program.

How do I create the exports for the C# dll and how would I access them from
a C executable or DLL.

If it can't be done using C, then how do you do it if you are using C++ ?

P.S. The C program is a Windows program.

Re: how to use a C# dll like a C dll

am 30.10.2007 02:43:04 von Andrew Faust

You can't access them as though they were a plain Win32 DLL because they
aren't. However, you can build a non-managed C++ app (don't know about C,
sorry) and tell the linker to include common language runtime support
(/clr). You would then add a reference to your C# library and then be able
to access it. Just beware that standard C++ and .Net assemblies are very
different beasts, so you'll be dealing with all sorts of fun issues
surrounding the passing of data back and forth.

Also, so far as I know this will only work with Microsoft compilers .Net
support is something they added. Other compilers such as Borland's and
Intel's may have added similar support but I don't use them so don't know.

--
Andrew Faust
andrew[at]andrewfaust.com
http://www.andrewfaust.com


"Relaxin" wrote in message
news:uVXrl5nGIHA.4476@TK2MSFTNGP06.phx.gbl...
>I want to create some DLL's in C# but they must be used in a C program.
>
> How do I create the exports for the C# dll and how would I access them
> from a C executable or DLL.
>
> If it can't be done using C, then how do you do it if you are using C++ ?
>
> P.S. The C program is a Windows program.