January 30th, 2013, 06:52 AM
Problem creating a DLL due to conflicts between MFC and .NET, Visual C++ 2008
I've already spent some hours trying to find a solution, but I couldn't, since I am not familiar with these settings, so I look for your help. This is the problem in detail:
I have a VC++ project to create a DLL that will be used as a Plug-in in an external programm. This DLL uses some MFC functions. The initial configuration of the project was:
-Use of MFC: Use MFC in a Static Library
-Common Language Runtime support: No Common Language Runtime support
-Runtime Library: Multi-threaded Debug (/MTd)
This configuration worked fine, there were no compilation errors and the resulting DLL worked correctly.
The problem came when it was necessary to add to the DLL some functions of .NET, using the namespace System and similar. To do that, I had to change the Common Language Runtime support, to Common Language Runtime Support (/clr). Then, when I tried to compile, I got this message:
'/MTd' and '/clr' command-line options are incompatible
So I changed the Runtime Library to Multi-threaded Debug DLL (/MDd). Then I got this error message:
Building MFC application with /MD[d] (CRT dll version) requires MFC shared dll version
So I also changed the Use of MFC to Use MFC in a Shared DLL.
After this, the compilation was correct. Then logically the size of the generated DLL is smaller, but this new DLL does not work correctly, the external programm in which this DLL is used crashes.
I don't know what to do to fix the problem. Maybe I need to add some other DLLs or files to the directory where the DLL is located, where the external programm uses it. But I would prefer to include a single DLL file, but this seems to be incompatible with the use of .NET functionalities.
Sorry for the long explanation. I would be very thankful is somedoby could help me.
I opened a thread about this in the wrong forum. The link is this:http://forums.codeguru.com/showthrea...=1#post2103441
Thank you in advanced.
Click Here to Expand Forum to Full Width
This a Codeguru.com survey!