Click here to Skip to main content
11,935,031 members (51,555 online)
Rate this:
Please Sign up or sign in to vote.
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

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 =

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
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

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

Solution 1

you should link the dll with the MFC libraries.
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.
KarstenK 27-Feb-13 2:09am
did you try ::FreeLibrary and are you shure for which dll it assertsß
Coder Block 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
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web03 | 2.8.151126.1 | Last Updated 25 Feb 2013
Copyright © CodeProject, 1999-2015
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