472,958 Members | 2,218 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,958 software developers and data experts.

assertion problem in Mixed mode DLL

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()
Nov 16 '05 #1
2 5366
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.
"Craig Klementowski" <no**************@nospam.hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
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()


Nov 16 '05 #2

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

"Ferdinand Oeinck" <ferdo@NO****@home.nl> wrote in message
news:bn**********@news1.tilbu1.nb.home.nl...
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.
"Craig Klementowski" <no**************@nospam.hotmail.com> wrote in message news:%2****************@TK2MSFTNGP12.phx.gbl...
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()


Nov 16 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Mike Kamzyuk | last post by:
Hello all. Basically, I need to call a mixed-mode dll's function (which uses managed code) from a native or mixed-mode dll function (which does not use managed code). I'm wondering if this could...
0
by: Edward Diener | last post by:
I have some questions about the instructions for creating a mixed mode DLL in the MSDN topic "Converting Managed Extensions for C++ Projects from Pure Intermediate Language to Mixed Mode" in the...
9
by: Edward Diener | last post by:
I received no answers about this the first time I posted, so I will try again. My inability to decipher an MSDN topic may find others who have the same inability and someone who can decipher and...
8
by: Bern McCarty | last post by:
Is it at all possible to leverage mixed-mode assemblies from AppDomains other than the default AppDomain? Is there any means at all of doing this? Mixed-mode is incredibly convenient, but if I...
8
by: Nadav | last post by:
Hi, I am writing a performence critical application, this require me to stick to unmanaged C++ as performance is much better using unmanaged C++ ( about 33% better ), Still, I am trying to avoid...
3
by: Ben Schwehn | last post by:
Hello I have a mixed mode c++ dll that i want to use from a c# project. However, I get an debug assertion when the dll is loaded. The assertion is in line 1301 in dbgheap.c in the function ...
2
by: Doug Belkofer | last post by:
We have created a fairly complex mixed-mode DLL that we want to use from VB.NET. The mixed-mode DLL is written in C++, and does use the standard C runtime libraries. An unusual thing is happening...
8
by: Edward Diener | last post by:
By reuse, I mean a function in an assembly which is called in another assembly. By a mixed-mode function I mean a function whose signature has one or more CLR types and one or more non-CLR...
0
by: emu | last post by:
Hi All, I have an unmanaged C++ application that references a mixed mode image DLL (mixed managed and unmanaged). Under .NET 1.1 we could trust the dll (the mixed mode dll) by running the...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
2
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.