How can I convert a Visual-C++ GUI project from app to DLL, and then have a C# app call the DLL and run the GUI?

When I try, the " dlg.DoModal();" causes "Debug Assertion Failed!".

I've got a visual studio 2010 C++ project with Config Props set for:
"Config Type is app (.exe)
Use MFC in a Shared DLL
Not Using ATL"

When I change it to DLL, select Common Lang Run Support (/clr), I can successfully call its individual functions from my C# solution.

I've tried calling a test function in the DLL that calls
"theApp.InitInstance();"
but this generates "Debug Assertion Failed!".