mfc >> Looking for a sample to develop DLL with managed C++

by Johnson » Wed, 13 May 2009 23:12:32 GMT

I have never written a DLL with managed C++, and a sample will help me
lots. Could anybody please recommend me a link?

Thank you!

mfc >> Looking for a sample to develop DLL with managed C++

by Giovanni Dicanio » Wed, 13 May 2009 23:32:14 GMT

"Johnson" < XXXX@XXXXX.COM > ha scritto nel messaggio

If you want to create a DLL with C++/CLI using Visual Studio 2008, you can
follow this menu path:

File | New | Project | Visual C++ | CLR

then choose "Class Library" template, and enter a project name, then click
OK button.

A skeleton project is created for you by Visual Studio.

For specific information on C++/CLI, you can practice with your favourite
search engine to find some tutorials on the Internet.
For example, there are some tutorials available here:

and articles written by Nish on CodeProject, e.g.


mfc >> Looking for a sample to develop DLL with managed C++

by Giovanni Dicanio » Wed, 13 May 2009 23:35:01 GMT

"Giovanni Dicanio" < XXXX@XXXXX.COM > ha scritto nel

BTW: A small addition: there is a specific newsgroup about C++/CLI, which
you may find helpful:


mfc >> Looking for a sample to develop DLL with managed C++

by Johnson » Thu, 14 May 2009 01:16:43 GMT

Thanks a lot!

mfc >> Looking for a sample to develop DLL with managed C++

by Giovanni Dicanio » Thu, 14 May 2009 01:22:17 GMT

"Johnson" < XXXX@XXXXX.COM > ha scritto nel messaggio

You are welcome.


Similar Threads

1. HOW TO: Call a Managed DLL from Native C++ Code sample

2. Managed C++ exe =to=> Managed C++ DLL

3. Sample of Unmanaged C++ code calling Managed C++

Does anyone have a simple "Hello World" like application that demonstrates 
unmanaged C++ calling managed C++ developed in VS2005?  I'm confused by many 
posts as they discuss managed extensions from VS2003, and related techniques. 
 I have found managed to unmanaged technique very easy in VS2005, but have 
not been able to build anything with unmanaged to managed calls.  I have 
legacy (unmanaged C++) that would like to leverage the .NET framework; I'd 
like to build a managed utility DLL that my unmanaged code can call.  How 
about this approach?

4. Looking for education materials of developing C++ application with Eclipse - Java

5. Wrap old C DLL in new unmanaged C++ / Managed C++ DLL

I have an old C DLL that I want to access via C#.

I'm doing this via an outer DLL that wraps the old C DLL in an unmanaged
C++ class, which is in turn wrapped in a Managed C++ class.  Both these
unmanaged C++ and managed C++ classes are compiled into a single assembly
(DLL) that is accessed by C#.

 [C DLL]  <-->  [Unmanaged C++ / Managed C++]  <-->  [C# app]
  old dll          new C++ assembly                                    app

I don't want to use standard Interop methods.  I'm trying to do all the
direct access to the old C DLL with unmanaged C++.  The data types in the
old C DLL are relatively complex, so I'm encapsulating the cluttered
legacy stuff in the new unmanaged C++ class.

IOW, I'll usually only be passing ints and a couple strings between the
unmanaged and managed sides.

In general, this approach works, but I'm getting occasional runtime errors
that I can't explain.  Could someone post or refer me to a very simple
example that does this with even a single function?  Say, take a function
from a stock Windows DLL and show a correct unmanaged C++ class
and managed C++ class that will wrap it correctly.

Thanks for any insights you can provide.

6. How to develop managed C++ app in 2003

7. developing managed c++ library


I try to develop a .Net class library using managed c++ and have several 

- If I use operator new, I get a linker error because operator new is 
missing. Searching the web I found out, that this is a well known 
problem which has to do with the initialization of the C/C++ runtime 
libraries. The proposed workaround looks not very promissing. But why 
would somebody use managed C++ is you could not use common C++ features?

- I develop a library to work with AVI files. If I include windows.h and 
wfw.h in different source units, I get a linker error concerning 
metadata. Searching the web I found out that the reason seems to be, 
that structures with the same name are defined twice with differnt 
layout. How could this happen if I use standard include files?

Could somebody help? At the moment, managed C++ makes no sense at all to me.


8. Looking for a sample C++ project