The Managed Extensions for C++ make it possible to mix native and managed code freely, even in the same module. Wow, life is good! Compiling with /clr, however, has consequences you may not want. It forces multithreading and dispenses with some useful runtime checks. It interferes with MFC’s DEBUG_NEW, and some .NET Framework classes may conflict with your namespace. And what if you have a legacy application that uses an older version of the compiler that doesn’t support /clr? Isn’t there some way to reach into the Framework without the Managed Extensions? Yes!
In this article, I’ll show you how to wrap Framework classes in a native way so you can use them in any C++/MFC app without /clr. As my test case, I’ll wrap the regex classes from the .NET Framework in a DLL and implement three MFC programs using it. You can use RegexWrap.dll to add regular expressions to your own C++/MFC applications, or use my ManWrap tools to wrap your own favorite Framework classes.
WOW! THIS IS COOL STUFF!!!!! I ALWAYS WANTED TO DO THIS; THE OTHER WAY AROUND FROM MANAGED TO UNMANAGED!! Enough of CAPS. This is cool. Alot of C++ guys will love this. Maybe I should fire up my passion for C++ again, since C++ is actually getting SOME recognition in the .NET environment, finally.