Turning a Visual C++ WinForm into a DLL
I have a WinForm app that I've created in Visual C++. For the most part it's managed, but I didn't write all the code so there may be some unmanaged code as well.
I want to use the code as a DLL for another .Net C# project I'm working on.
Currently, I've managed to do this by taking the following steps in my C++ WinForm.
1) Under Project's Property Pages, I've set Configuration Properties->General->Configuration Type = Dynamic Library (.dll)
2) Under Project's Property Pages, I've set Configuration Properties->Linker->General->Output File = $(OutDir)\$(ProjectName).dll
I then build a release version and when VisStudio asks me to select a debugger I simply cancel.
I can now add this Dll to my C# project by adding it as a reference. I can then access the WinForms members. This works. :-D
The reason why I'm posting this question, is I'm pretty sure (if I'm understanding the postings correctly) that there's a bug with mixed Dlls written in C++. I've read several of the Microsoft articles and it appears the best solution to overcome this problem is to set the link flag: /noentry.
When I do this, however, I get
error LNK2019: unresolved external symbol _main referenced in function _mainCRTStartup
I've tried to search for information on this particular linker error. I think what's happening is that since I originally wrote a standalone WinForm .exe, the linker is maybe trying to find the _main entry point but because I've changed the compile/link options to not have an entry, this symbol is never being resolved. Clearly soemthing wants an entry point...
What's the best solution to my problem? Do I keep what works? Or is there some way to resolve this _main reference while keeping my DLL from having issues.
Any help would be greatly appreciated,
Thanks,
Nate

