/clr and nonmanaged libraries

With Visual C++ mixing managed and unmanaged code is always interesting. It either just works, or your application dies horribly before reaching the main entry point. Debugging in the pre-main world of static data registration and atexit handlers is not very fun. Fortunately a post made by Jeffrey Tan of Microsoft Online Community Support provides a solution:

By further discussing with a developer from VC++ team, he confirmed that
this was a known issue. The main problem here is that the IDE is specific
the entry of ManagedApp as “main”. However, using “main” will bypass a lot
of CRT’s startup initialization. The fix here is to simply change the
entry point in the IDE. Under ManagedApp -properties-link -advanced,
change “entry point” from “main” to
“?mainCRTStartupStrArray@@$$FYMHP$01AP$AAVString@System@@@Z”. That should
re-enable the CRT startup code which initializes the internal CRT variables.

Original discussion can be found here.