Sample code for wrapping C++ DLL into .NET assembly

  • Thread starter Thread starter John Lee
  • Start date Start date
J

John Lee

Hi,

I understand we could use p/Invoke to access most of the C/C++ DLL but there
are some cases the functions can only be accessed by C/C++ so it would be
good if I could create a .NET class to wrap around those functionalities.

Could someone point me an example of how to use VS C++.NET to do this? Any
tips will be highly appreciated!

Thanks very much!
John
 
Hi John,
I understand we could use p/Invoke to access most of the C/C++ DLL but there
are some cases the functions can only be accessed by C/C++ so it would be
good if I could create a .NET class to wrap around those functionalities.

Based on my understanding, you want to wrap the native C/C++ classes in a
..NET assembly, if so I suggest you can refer to the following MSDN
documentation and an article from the Codeguru, which introduce the general
techniques on wrapping unmanaged C++ classes with Managed Extensions for
C++ classes that act as proxies:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcmxspec/ht
ml/vcmg_overview.asp

Head-Spinning Continued: The Managed Wrapper
http://www.codeguru.com/Cpp/Cpp/cpp_managed/interop/article.php/c4863/


However, if you just have concern on a non-COM interop scenario, such as
implementing a flat handle-style DLL API in a .NET assembly, then you can
find the solution and code samples in this Codeguru's article:

Interop: A Look at Managed C++
http://www.codeguru.com/Cpp/Cpp/cpp_managed/interop/article.php/c4845/


Hope this help!

Best regards,

Gary Chang
Microsoft Community Support
--------------------
Get Secure! ¡§C www.microsoft.com/security
Register to Access MSDN Managed Newsgroups!
http://support.microsoft.com/default.aspx?scid=/servicedesks/msdn/nospam.asp
&SD=msdn

This posting is provided "AS IS" with no warranties, and confers no rights.
 
Back
Top