
managed c++ vs unmanaged c++
Don't cross post, its not good manners.
Quote:
> 1) What is the role of STL in Managed world?
It is used for templated containers for unmanaged types.
Quote:
> 2) Can we use Unmanaged Libraries ( Dll's / C++ classes / C++ classes
> encapsulated in dlls ) in Managed Applications? (and vice versa) if yes is
> there any complete example available ?!
Yes, managed C++ comes with a technology called It Just Works (called that
because it does). You don't have to do anything to use IJW other than use an
unmanaged static library, or call an exported DLL function. Using managed
types in unmanaged applications is a little more involved. There are two
ways to do this, the easiest way is to use regasm to register the .NET
assembly as a COM server and then use tlbexp to export the metadata as a
type library and use #import in your native C++ application so that you can
call the classes. The downside of this is that the .NET must be in the GAC
or you must use /codebase with regasm which 'fixes' the assembly to one
location on your hard disk. The other way that you can call .NET classes
from unmanaged C++ is to use the hosting interfaces. In affect you
explicitly load the CLR into your process, creating an AppDomain where you
can call .NET classes to load types and execute them. The downside of this
is that it is extremely tedious because many of the .NET classes have
overloaded methods, and .NET distinguishes between them using numerical
suffixes, and as far as I can tell there is no obvious way to tell which
overload corresponds to which suffix. Furthermore, most of the framework
classes are exported through COM as automation interfaces rather than dual
interfaces (there are good reasons for this, which I won't go into here)
which makes the coding tedious from C++.
Richard
--
Richard Grimes [MVP]
author: "Programming with Managed Extensions for Visual C++ .NET",
the Microsoft Press book about Managed C++