From: Tom Serface on
OP will want to be sure to call AfxSetResourceHandle() to reestablish a
resource base or there could be an error when the next resource is needed.
In a DLL you would want to be sure to have a valid set of resources (either
built in or from a satellite DLL) at all times or when a resource is needed
an ASSERT would almost certainly happen. I'm not sure if this is the same
thing or not since I have not experienced this specific problem.

Tom

"David Ching" <dc(a)remove-this.dcsoft.com> wrote in message
news:X_l2k.3545$uE5.2048(a)flpi144.ffdc.sbc.com...
> "Sunny" <sound_of_nature(a)hotmail.com> wrote in message
> news:uihtiw4xIHA.420(a)TK2MSFTNGP02.phx.gbl...
>> Regular DLL
>>
>> Now i find the error location.
>> this shoule be a bug of new mfc version.
>>
>> In the CMFCVisualManagerOffice2007 ,when the style is changing , the
>> function SetStyle of CMFCVisualManagerOffice2007 auto call FreeLibrary
>> to free the dll, so the error happend.
>>
>
> I don't see how freeing your resource dll caused an error. If your
> resource dll is similar to the one it replaces, it shouldn't matter that
> it is freed.
>
> -- David
>
>

From: Sunny on
Look at line 19 and line 28-31. it's the code in mfc9.0.

1 BOOL __stdcall CMFCVisualManagerOffice2007::SetStyle(Style style, LPCTSTR
lpszPath)
2 {
3 if (m_Style == style && m_hinstRes >(HINSTANCE) 32)
4 {
5 return TRUE;
6 }
7
8 UNREFERENCED_PARAMETER(lpszPath);
9 CString strStyle(GetStyleResourceID(style));
10 HINSTANCE hinstRes = AfxFindResourceHandle(strStyle, AFX_RT_STYLE_XML);
11
12 if (::FindResource(hinstRes, strStyle, AFX_RT_STYLE_XML) == NULL)
13 {
14 TRACE(_T("Cannot load Style: %s\r\n"), strStyle);
15 ASSERT(FALSE);
16 return FALSE;
17 }
18
19 CleanStyle();
20 m_Style = style;
21 SetResourceHandle(hinstRes);
22 m_bAutoFreeRes = TRUE;
23
24 return TRUE;
25}

26 void __stdcall CMFCVisualManagerOffice2007::CleanStyle()
27 {
28 if (m_bAutoFreeRes && m_hinstRes >(HINSTANCE) 32)
29 {
30 ::FreeLibrary(m_hinstRes); //here the dll is freed,so error happen.
31 }

32 m_hinstRes = NULL;
33 m_Style = c_StyleDefault;
34 m_strStylePrefix.Empty();
}


First  |  Prev  | 
Pages: 1 2
Prev: Memory leaks
Next: Disk or network error