Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C++ Libraries / October 2003

Tip: Looking for answers? Try searching our database.

assertion problem in Mixed mode DLL

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Craig Klementowski - 27 Oct 2003 17:20 GMT
Pardon the cross post, but I'm not sure where exactly to post this question.

We have MFC application using many MFC extention DLL's. We started using a
new MFC extention DLL that is mixed mode so we could use some .Net
components we have built.

We are getting an assertion in ~CCmdTarget when exiting our app when after
making a call to Windows Forms MessageBox. On line 48, m_dwRef is 2 for some
reason.

Offending line - System::Windows::Forms::MessageBox::Show("Test");

Is there some function I need to call to release something that I am
missing? Any ideas?

Thanks...

Craig Klementowski

CCmdTarget::~CCmdTarget()
{
#ifndef _AFX_NO_OLE_SUPPORT
if (m_xDispatch.m_vtbl != 0)
((COleDispatchImpl*)&m_xDispatch)->Disconnect();

>>>>>>>>>ASSERT(m_dwRef <= 1);

#endif
#ifdef _AFXDLL
m_pModuleState = NULL;
#endif
}

Call Stack:

> mfc71d.dll!CCmdTarget::~CCmdTarget()  Line 48 + 0x19 C++
 mfc71d.dll!COleMessageFilter::~COleMessageFilter()  Line 59 + 0xf C++
 mfc71d.dll!COleMessageFilter::`scalar deleting destructor'()  + 0xf C++
 mfc71d.dll!AfxOleTerm(int bJustRevoke=0)  Line 114 + 0x22 C++
 mfc71d.dll!AfxOleTermOrFreeLib(int bTerm=1, int bJustRevoke=0)  Line 139
C++
 mfc71d.dll!AfxWinTerm()  Line 48 C++
 mfc71d.dll!AfxWinMain(HINSTANCE__ * hInstance=0x00400000, HINSTANCE__ *
hPrevInstance=0x00000000, char * lpCmdLine=0x0024237f, int nCmdShow=5)  Line
64 C++
 MyApp.exe!WinMain(HINSTANCE__ * hInstance=0x00400000, HINSTANCE__ *
hPrevInstance=0x00000000, char * lpCmdLine=0x0024237f, int nCmdShow=5)  Line
25 C++
 MyApp.exe!WinMainCRTStartup()  Line 390 + 0x39 C
 kernel32.dll!77e814c7()
Ferdinand Oeinck - 27 Oct 2003 19:34 GMT
I Craig,

what a coincidence! I installed last weekend Windows Server 2003 and Visual
Studio 7.1 on my new dual xeon dell system and after I copied my project
directory and compiled my most important app, I got exaclty the same failed
assertion as you do.

I cured it by carefully removing all unnessesarry calls to CoInitializeEx
and CoUninitialize. Now there is only one call to AfxOleInit() and the
assertion failure went away. A strange thing is that my app worked great in
DEBUG mode on w2k without any assertion failure. So Microsoft has changed
something in OLE....

But there is another point of concern about your code. As from what you
describe, you can become a victim of the .Net loaderlock issue very easily.
You do not tell us if you load the CLR with CorBindToRuntimeEx in your MFC
app. I you do not, then you could have a big change to run into the loader
lock issue!

Search for 'loader lock issue' on Google....

Ferdinand.

> Pardon the cross post, but I'm not sure where exactly to post this question.
>
[quoted text clipped - 46 lines]
>   MyApp.exe!WinMainCRTStartup()  Line 390 + 0x39 C
>   kernel32.dll!77e814c7()
Craig Klementowski - 29 Oct 2003 16:38 GMT
We carefully read what the MSDN said and did that so we should be safe from
the loader lock issue.

I'll try and cleanup the CoInitializeEx, CoUninitialize, and AfxOleInit
calls.

Thanks,

Craig

> I Craig,
>
[quoted text clipped - 73 lines]
> >   MyApp.exe!WinMainCRTStartup()  Line 390 + 0x39 C
> >   kernel32.dll!77e814c7()

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.