Cannot register my OCX with VS.Net 2005  
Author Message
Wassim





PostPosted: Visual C++ General, Cannot register my OCX with VS.Net 2005 Top

Hello,

I have an OCX that was originally written in Visual C++ 6. After upgrading to VS.Net 2003 everything worked fine and I was able to register my OCX. Recently, I tried to upgrade to VS.Net 2005 but had a lot of trouble registering my OCX. I managed to fix many problems related to the OCX registration but I ended up with the following situation:

If I compile in "Debug" mode, the compile succeeds and the OCX gets registered (I can see this in the registry). However, when I try to test the OCX using ActiveX Control Test Container I get a debug assertion in File: f:\rtm\vctools\vc7libs\ship\atlmfc\include\afxwin1.inl Line: 21

Note that f: is my CD\DVD drive. You can also notice the VC7Libs in the path which refers to the previous version of VS.Net I guess.

When I compile the same OCX in "Release" mode, I get a runtime error in regsvr32 while VS.Net is attempting to register the OCX. The error is:

R6033

- Attempt to use MSIL code from this assembly during native code initialization...

Note that I'm compiling the OCX with "No CLR support" but it depends on other DLLs which are compiled with /clr.

I did some tracing and found that the crash is happening inside DllRegisterServer which does not use any managed code. I also noticed that AfxGetInstanceHandle is returning NULL which might be causing the crash.

I tried compiling my OCX with /clr but VS.Net hangs while trying to register it.

I'm using the VS.Net integrated registration in the project settings instead of using regsvr32 in the post build steps.

I really appreciate your help.

Regards,

Wassim



Visual C++7  
 
 
Ted.





PostPosted: Visual C++ General, Cannot register my OCX with VS.Net 2005 Top

line 21 corresponds to

_AFXWIN_INLINE HINSTANCE AFXAPI AfxGetInstanceHandle()
 { ASSERT(afxCurrentInstanceHandle != NULL);

It shows up in a weird path (f:rtm\vctools etc) because that's where VC was built at the Microsoft corporation offices.  The PDB always contains the path where it was originally built.   Just ignore that weird path and just use the file name and find it in your own source code (i.e. at \Program Files\Microsoft Visual Studio 8\vc\atlmfc\ etc)

Normally when you get a null instance handle, it is due to a missing AFX_MANAGE_STATE somewhere in your code.

So try debugging the process by setting up the activex control container in the de**** and stepping through your code to see where it's failing.

For more info, see

http://www.hide-link.com/


 
 
Wassim





PostPosted: Visual C++ General, Cannot register my OCX with VS.Net 2005 Top

Thank you for replying

Debugging the application shows that the crash is happening in __DllMainCRTStartup at line
retcode = (*_pRawDllMain)(hDllHandle, dwReason, lpreserved);
The _pRawDllMain function pointer contains an invalid address. If I include "afxdllx.h" in my StdAfx.h the previous problem goes away but I get another crash in
AfxCoreInitModule() at line:
ASSERT(AfxGetModuleState() != AfxGetAppModuleState());

Note that I'm using stingray studio as a third party library. Everything works fine under VS.Net 2003.

Regards,

Wassim.


 
 
White Paladin





PostPosted: Visual C++ General, Cannot register my OCX with VS.Net 2005 Top

I am working on converting a DLL used as an extension to Word to Visual Studio 2005.  This DLL has been around since v6.0 of Visual Studio.  I am having a similar problem in AfxCoreInitModule() at line 573:
ASSERT(AfxGetModuleState() != AfxGetAppModuleState());

Luckily for me my dll does not crash at this line, but only ASSERTs.  Running in debug I don't see any place to put code to affect this ASSERT.  I also don't know what code I would change to affect this ASSERT.

I see this ASSERT when running regsvr32 and when running Word with this DLL.  Is it possible that this DLL should not be an AFXDLL

Any help would be appriciated.  Thank you,
Brett


 
 
BorisM





PostPosted: Visual C++ General, Cannot register my OCX with VS.Net 2005 Top

For Stingray Studio, this problem was resolved. Please, see Utility Tool for StingrayR Studio 2006, you can download it from http://www.roguewave.com/developer/tac/.