Monday, February 15, 2010

Control registration failed after compiler upgradation to VS2008

Recently we upgraded our products from VS2005 to VS2008 and then we got a problem with the registration of our controls which were originaly created by VC6.0. After some investigation we found out that the DLL function RawDLLMain wasn't called in the newly generated controls when registering the control. The function RawDLLMain for user DLL is defined in C:\Program Files\Microsoft Visual Studio 9.0\VC\atlmfc\src\mfc\dllmodule.cpp, while the one for MFC90u(d).dll is defined in dllinit.cpp.

If you have a look at rawdllmainproxy.c in the same folder, you will find the following comments.

/* _RawDllMainProxy is used to correctly call RawDllMain (defined in dllmodul.cpp).
* We need to call RawDllMain only when the user does not provide his/her own DllMain.
* _RawDllMainProxy will check the value of _pActualRawDllMain: such function pointer
* will point to RawDllMain only if dllmodul.obj is pulled in by the linker (and this
* usually happens if the user define the _USRDLL macro). If dllmodul.obj is not pulled
* in, _pActualRawDllMain (being a communal) will be NULL, so _RawDllMainProxy will
* simply return.
*/

Then we tried to define the preprocessor _USERDLL in VS2008 project, wow, it workd.

So, this might be the case that you have to explicitly define the preprocessor _USERDLL in your VS2008 project.

No comments:

Post a Comment