How do I use a class developed by VC++6.0 in C#?
A full length tutorial on how this can be done is beyond the scope of this answer. However here is a background:
C# supports calling unmanaged code. Depending on the type of C++ project, you may be able to call it using COM Interop or PInvoke.
===== 1. Platform Invocation Service: ===== Platform Invoke Services acts as a bridge between the managed and unmanaged code. They enable the managed code to call the functions which are being exposed by the dynamic link libraries such as Win32 API’s and custom DLL’s.
Supply a DllImport attribute. Declare the methods in your .NET code as static extern. Do not implement the methods as they are implemented in your unmanaged code, you’re just providing declarations for method signatures.
===== 2. COM Interop Services: ===== This enables the managed code to interact with the COM objects. One way is you use the Type Library Import utility shipped with SDK. tlbimp COMobject.dll /out:.NETobject.dll or reference the COM library from Visual Studio in your project.
You can reference the Microsoft’s MSDN site for detailed examples and tutorials.
Index