As has been pointed out, the only way to make native classes available to
managed code is to write managed adapters (you'll likely have to change
attributes or behaviour slightly, so they're usually more than
just "wrappers").

In C++/CLI, you can simply write managed classes and instantiate and use
unmanaged classes (whose source is in the same project or link to native
LIBs or DLLs).  This "magic" is C++ Interop (or Implicit Pinvoke) in
Visual C++ 2005.  This was referred to in Visual C++ 2003 as "It Just
Works" (IJW).  You can sometimes find a bit of overlap of the two
terms ,IJW and C++ Interop, between VC2k3 and VC2k5; but C++ Interop is
far more common with VC2k5.

In any event, there's some good references on C++ Interop, like in the
Visual C++ programming guide: http://msdn2.microsoft.com/en-
us/library/2x8kf7zx(VS.80).aspx and specific examples of wrapping a native
C++ class for use in C#: http://msdn2.microsoft.com/en-us/library/ms235281
(VS.80).aspx

The pimpl idiom is often used to implement managed adapters for native
classes, if you're not familiar with that you might want to look at
references like http://www.codepedia.com/1/CppPimpl or
http://www.devx.com/cplus/Article/28105 or http://www.gotw.ca/gotw/024.htm

I've written managed adapters to native classes in both VC2005 and VC2003,
so feel free to post further questions about this approach...

Are you writing for .NET 2.0 or .NET 1.x?  Are you dealing with any LIBs
or DLLs?

On Fri, 16 Nov 2007 11:24:57 -0500, Mark Nicholls
<[EMAIL PROTECTED]> wrote:

>Hello,
>can someone give me some advice about calling a unmanaged C++ dll from
>C#.....it also uses templates from the STL......it all sounds a bit
>horrible....any advice....or (good) articles on the web somewhere.

===================================
This list is hosted by DevelopMentorĀ®  http://www.develop.com

View archives and manage your subscription(s) at http://discuss.develop.com

Reply via email to