Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C++ Windows MFC Win2008 library , +
Hi guys,
Its strange or may be my fault of coding please provide me any solution related to this.Frown | :-( ..
 
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,
		// 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 15-Feb-13 17:49pm
Edited 15-Feb-13 20:18pm
v2
Comments
merano at 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

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

you should link the dll with the MFC libraries.
  Permalink  
Comments
Coder Block at 25-Feb-13 6:49am
   
dear i want to use dynamic liking and not static liking...
KarstenK at 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 at 25-Feb-13 23:24pm
   
FreeLibrary also gives assertion on same point..
KarstenK at 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 at 26-Feb-13 22:15pm
   
i dont know how may be my coding problem but it assert.
KarstenK at 27-Feb-13 2:09am
   
did you try ::FreeLibrary and are you shure for which dll it assertsß
Coder Block at 1-Mar-13 2:04am
   
yap i also tried it on window 8 with free library too.

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

  Print Answers RSS
0 Maciej Los 205
1 Richard MacCutchan 185
2 DamithSL 170
3 Tomas Takac 146
4 OriginalGriff 132
0 OriginalGriff 5,130
1 DamithSL 4,237
2 Maciej Los 3,700
3 Kornfeld Eliyahu Peter 3,470
4 Sergey Alexandrovich Kryukov 2,846


Advertise | Privacy | Mobile
Web02 | 2.8.141216.1 | Last Updated 25 Feb 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100