Hey there guys, I have been using c# and c++ for sometime now and have found it to be alright However, recently I needed to instantiate a c++ class, stored in an unmanaged dll in c#. And since then, have got nowhere. < xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />
Does anyone know how to instantiate an unmanaged c++ class, in c# And if possible without having to use c++ with managed extensions
Yours - Ali

unmanaged c++ class in c#
Amit Barde
Hi - there thanks for the speedy reply.
My problem is that, I’m have a unmanaged c++ .DLL, which contains c++ classes (objects), rather than just functions, and I would like some way of interfacing with this .DLL in c#, which would allow me to gain access to theses objects, and instantiate more than one instance of them. Which is the best way of achieving this, a COM wrapper, MC++ interface, or some other idea < xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />
Could you also provide a bit of source code, as I do not know much COM, or MC++
Cheers
Alistair
Carlton Lane - MSFT
Hi there Paul
I'll have a go at creating a managed c++ wrapper, although I don’t have much experience in using it, and I’ll let you know how I get on. Although I would appreciate it if anyone has any ideas about writing a wrapper in managed c++.
Thanks
Ali
billhu
you cannot instanciate an unmanaged c++ class from c#. You can achieve this from c++ with managed extensions project, as you already know.
Could you describe what you are willing to achieve
Thibaut
[blog] http://www.dotnetguru2.org/tbarrere
Ralph_Ai2x
have you already read those articles by Sam Gentile
http://www.ondotnet.com/pub/a/dotnet/2003/01/13/intromcpp.html
http://www.ondotnet.com/pub/a/dotnet/2003/03/03/mcppp2.html
http://www.ondotnet.com/pub/a/dotnet/2004/03/29/mcpp_part3.html
I've also gathered a couple of KB's references and articles about mixed-mode dlls (there are definitely things to know if you're writing your wrapper with VS.Net 2003) on my blog:
http://www.dotnetguru.org/blogs/tbarrere/ p=48&more=1&c=1&tb=1&pb=1
HTH
Thibaut Barrere
marcin.walus
Hi,
Since C++/CLI allows integration between managed and unmanaged code. Then I suggest you create a managed wrapper instead of a com wrapper. As I understand a wrapper is just a small class that encapsulates all the features of the wrapped class... If my understandings are right, then I suggest you create a managed class which would expose the functionalities of your unmanaged class...
cheers,
Paul June A. Domag
willstewca
Hi,
Are you using VS2003 or VS2005 There was a Managed C++ overhaul. The syntax has greatly been remodeled in VS2005. It looks more like C# instead of the __gc underscores that you could see in VS2003...
cheers,
Paul June A. Domag