几何尺寸与公差论坛------致力于产品几何量公差标准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)
-   -   【转帖】access violation exception with wingdi (http://www.dimcax.com/hust/showthread.php?t=15009)

yang686526 2009-05-04 03:30 PM

【转帖】access violation exception with wingdi
 
access violation exception with wingdi
access violation exception with wingdi
i'm trying to use the wingdi system to render a view of a dwg file in a windows forms application. compiling under visual studio 2005 with default forms application settings except clr support rather than clr pure mode. using the latest dwgdirect libraries (2.2.)
starting with a blank control similar to how i've previously created mixed forms/opengl applications. since the application i was working on originally didn't work i have created the simplest clear code base that reproduces the same problem. in this simplified version i have a function which is called after the control initialisation is finished (visible on the screen) that does the following:
code:
odrxobjectimpl<exhostappservices> hostappservices;
odrxobjectimpl<exsystemservices> systemservices;
odinitialize(&systemservices);
odgsinitialize();
oddbdatabaseptr pdb = hostappservices.readfile(l"c:\\test.dwg");
if (pdb.isnull()) {
throw gcnew exception("error opening database");
}
odgsdeviceptr pdevice = exgsscreendevice<exgsgdivectorizedevice>::createobject();
if (pdevice.isnull()) {
throw gcnew exception("error creating gdi render device");
}
odrxdictionaryptr pproperties = pdevice->properties();
pproperties->putat(l"windowhwnd",odrxvariantvalue( (odint32)this->handle.toint32() ));

odgicontextfordbdatabaseptr pdwgcontext;
pdwgcontext->setdatabase(pdb);
pdevice = oddbgsmanager::setupactivelayoutviews(pdevice,pdwgcontext);
the code throws system.accessviolationexception from a point inside dd_db_2.02_8.dll when making the setupactivelayoutviews method.
i get a few linker warnings when compiling of the unresolved typeref token variety, but the code i write with the library seems to work otherwise. i've tested accessing text objects in the database to verify that it has opened for reading fine. pdf exporting works fine as well so the problem is fairly localized.
can anyone offer suggestions?
an update to this, i tried using the code as a module as suggested in another thread, and i get the same error from the same call. still not sure what to do about it
last edited by davidenglish; 1st march 2007 at 10:38 pmfff">.
did you read this:
?
if yes, and the problem persists, perhaps you may create a sample and send us to look at?
vladimir
yes i read that, have tried doing it by linking the gdi code in directly and calling odgsinitialize manually, and also by using the dynamic module (as in the sample.) similar error from the same call either way. i also tried using
attached a sample. i've simplified the code to the absolute minimum to reproduce the error. if you can shed any light on where i'm going wrong that'd be great, cheers!
attached files (179.2 kb, 18 views)

code:
odgicontextfordbdatabaseptr pdwgcontext;
pdwgcontext->setdatabase(pdb);
is the same as
code:
odgicontextfordbdatabase* pdwgcontext;
pdwgcontext->setdatabase(pdb);
note also that to do anything else than setupactivelayoutviews, you will need to store hostappservices, systemservices and gsdevice somewhere.
vladimir
apologies for that, i dropped the create object by mistake when i was simplifying the code to trace the problem.
similarly i wasn't storing the other objects anywhere because i was just trying to minimise code, they are retained in my original code base.
still not sure why the original doesn't work, but the sample appears to now, so i'll keep looking.
cheers


所有的时间均为北京时间。 现在的时间是 12:37 PM.