Accessing VC++ classes from .NET

V

vemulakiran

Hi all,
I have doubt regarding .NET.
I have a tool which was developed on VC++ 6.0(Win32 Application ).
The application communicates with library (API) which was developed on
VC++ 6.0 called core client.
I am planning to develop the tool or Win32 application on .NET
platform and I dont' want to migrate the VC++ library (API) to .NET.
The new .NET tool should use the previous VC++ library API ( core
client ).
Is there any possibility to call VC++ 6.0 source file ( .CPP ) or
APIs from .NET ( C# or VC++.NET )..? IF so, would u please suggest me a
usefull link or tell me How can I do it. I dont' want to make the
existing VC++ core client into DLL and add it as a reference to .NET
project.

Thanks for you kindly help
Regards
Kiran
 
G

Guest

You’ve got a few options, listed below in order of appeal. First up though,
you cannot directly call or add a .CPP file to/from a C# application given
that they are two different languages, you can do so with some wrappers or
rewrites ala:

1. Depending on how your VC++ 6 DLL is structured, you can use P/Invoke to
access the methods and classes contained within from your C# app.

2. Add your .CPP file to a VC++.NET Class Library that is in turn referenced
by your C# application.

3. Rewrite your C++ code in C#.

Personally, I would suggest going with #1 as you already have the DLL built
and working.

Brendan
 
W

Willy Denoyette [MVP]

Hi all,
I have doubt regarding .NET.
I have a tool which was developed on VC++ 6.0(Win32 Application ).
The application communicates with library (API) which was developed on
VC++ 6.0 called core client.
I am planning to develop the tool or Win32 application on .NET
platform and I dont' want to migrate the VC++ library (API) to .NET.
The new .NET tool should use the previous VC++ library API ( core
client ).
Is there any possibility to call VC++ 6.0 source file ( .CPP ) or
APIs from .NET ( C# or VC++.NET )..? IF so, would u please suggest me a
usefull link or tell me How can I do it. I dont' want to make the
existing VC++ core client into DLL and add it as a reference to .NET
project.

Thanks for you kindly help
Regards
Kiran

There is no way to use C++ native classes directly from C#, the only
language that supports this scenario is VC++ .NET using it's Managed
Extentions (ME C++), but I would suggest you to wait for VS2005 C++/CLI to
become available (RTM November). Using ME C++ or C++/CLI you can author
managed classes that wrap your native classes, another option is to author
the tool using ME C++ or C++/CLI so you can directly access the native
classes (after recompiling the sources).


Willy.
 

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