Click here to Skip to main content
15,884,836 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
Hi guys,
Its strange or may be my fault of coding please provide me any solution related to this.:-(..

I have developed one windows based application(VC++ MFC document-view architecture) in visual studio 2003. In this application I am using Static DLL. To load and free the library following functions are being used : AfxLoadLibrary and AfxFreeLibrary

Architecture is as follows:-
ABC :: Main document-view project.
PQRDLL :: DLL project.
LMNDLL :: DLL project.

The flow of project execution:
1. ABC calls PQRDLL
2. PQRDLL calls LMNDLL,

In InItInstance() of PQRDLL, LMNDLL is loaded using AfxLoadLibrary and on ExitInstance() of PQRDLL ,LMNDLL is unloaded using AfxFreeLibrary.

The same application is running without any problem on Windows XP/Vista/7 (32/64) bit systems. But when I run it on window 8 I get debug assertion in DLLModul.cpp file on line number 124.

that is on,
C++
		// set module state for cleanup
assert=====>    ASSERT(AfxGetThreadState()->m_pPrevModuleState == NULL);
		AfxGetThreadState()->m_pPrevModuleState =
			AfxSetModuleState(&afxModuleState);


I am not able to debug the code on windows 8 system as visual studio is not installed so I am debugging the problem using message boxes.

I tried a lot but I really not understand what exactly goin on.
I would request you all to please provide me the solution for this problem.
Thanks in advance.
Posted
Updated 15-Feb-13 19:18pm
v2
Comments
merano 16-Feb-13 20:56pm    
What do you mean with "Static DLL" ?
Did you link MFC static ?
You should not link MFC static for a DLL. You are never shure what Version
the Main-application is running with.

1 solution

you should link the dll with the MFC libraries.
 
Share this answer
 
Comments
Coder Block 25-Feb-13 6:49am    
dear i want to use dynamic liking and not static liking...
KarstenK 25-Feb-13 6:52am    
That iant the point with AfxFreeLibrary you only can unload MFC dlls. Your dlls without MFC you better use FreeLibrary
Coder Block 25-Feb-13 23:24pm    
FreeLibrary also gives assertion on same point..
KarstenK 26-Feb-13 2:54am    
You use ::FreeLibrary( myHandle ) and it asserts??? Pay attention to the "::" before "FreeLibrary"

I dont believe it :-O

It is some mix of MFC and non-MFC calls which need to be avoided
Coder Block 26-Feb-13 22:15pm    
i dont know how may be my coding problem but it assert.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900