C programming interface for .NET based Library

G

Guest

Hi All,
We have a .NET library having .NET remoting based programming interface
developed using VC++.NET (VS 2005 Beta2).

We want to provide C interface for a legacy application. Is it possible?
If yes, what would be the best approach?

Regards,
RS
 
W

William DePalo [MVP VC++]

Ratan said:
We have a .NET library having .NET remoting based programming interface
developed using VC++.NET (VS 2005 Beta2).

We want to provide C interface for a legacy application. Is it possible?
If yes, what would be the best approach?

You can use the assembly registration (regasm) utility

http://msdn.microsoft.com/library/d...ml/cpgrfassemblyregistrationtoolregasmexe.asp

to "create" a COM object and type library from your .Net classes. Your C
application makes use of your .Net classes just as it would any other COM
object. I sketched the procedure with a toy .Net class and a C++ caller
here:

http://groups.google.com/group/micr...*+author:depalo&rnum=2&hl=en#8b7cc21dc2b67f3d

If C++ rather than C is an option you can create an unmanaged C++ class (or
classes) which has one public method for every method of every class in your
..Net solution. Then the C++ application can use the "it just works" method
of interop

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndotnet/html/manunmancode.asp

so that every call to one of these unmanaged methods is implemented by
calling on the corresponding managed method.

Regards.
Will
 
J

Jochen Kalmbach [MVP]

Hi Ratan!
We have a .NET library having .NET remoting based programming interface
developed using VC++.NET (VS 2005 Beta2).

We want to provide C interface for a legacy application. Is it possible?
If yes, what would be the best approach?

There are several ways to do this:
- COM-Interop (regasam as William said already)
- CLR-Hosting
- Managed C++ (if you write a DLL this might be possible; never tested
it...)

For more infos see:
http://www.gotdotnet.com/team/clr/what_is_clr_hosting.aspx


--
Greetings
Jochen

My blog about Win32 and .NET
http://blog.kalmbachnet.de/
 
G

Guest

Hi,

Thank you very much to *both of you* for your suggestion.
I will proceed according to your suggestions.

Regards,
RS
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top