几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量

几何尺寸与公差论坛------致力于产品几何量公差标准GD&T (GDT:ASME)|New GPS(ISO)研究/CAD设计/CAM加工/CMM测量 (http://www.dimcax.com/hust/index.php)
-   DirectDWG (http://www.dimcax.com/hust/forumdisplay.php?f=89)
-   -   【转帖】dll crashes (http://www.dimcax.com/hust/showthread.php?t=15757)

yang686526 2009-05-04 07:56 PM

【转帖】dll crashes
 
dll crashes...
dll crashes...
hi everyone,
i'm using dwgdirect in a dll, and i'm having this problem:
to create the graphical context on which to paint, i use this piece of code in the dll:
-------------------------------------------------------------
m_pdevice = getrendererdevice();
if(m_pdevice.isnull())
return;
m_hhelperdc = (hdc)hdc;
odrxdictionaryptr pproperties = m_pdevice->properties();
pproperties->putat("windowhdc", odrxvariantvalue(hdc));
if(pproperties->has("doublebufferenabled"))
{
pproperties->putat( "doublebufferenabled", odrxvariantvalue(doublebufferenabled()));
}
m_pdevice->setbackgroundcolor(activebackground());
m_pdevice->setlogicalpalette(curpalette(), 256);
if( !database() )
return;
int n = m_pdevice->numviews();
m_pdevice = oddbgsmanager::setupactivelayoutviews(m_pdevice, this);
setviewportborderproperties(m_pdevice, true);
-------------------------------------------------------
where hdc is the hdc passet to the dll by the client application.
the problem is:
when the dll is unloaded, i use this function:
-------------------------------------------------------------------
int crendererdllapp::exitinstance()
{
m_pdb = null;
if(m_gsmoduleid)
{
m_pgs.release();
:drxdynamiclinker()->unloadmodule(m_gsmoduleid);
m_gsmoduleid = 0;
}
:duninitialize();
return cwinapp::exitinstance();
}
---------------------------------------------------------------------
and here everything seems to be ok, but, in the client application everything crashes in this piece of mfc code:
afxgetmodulestate()->m_bdll
any idea about the reason ????
my dll is a mfc dll with mfc dynamically linked, in the exported funcions of the dll i put the
afx_manage_state(afxgetstaticmodulestate());
macro.


所有的时间均为北京时间。 现在的时间是 10:36 AM.