system.accessviolationexception when it writes a dwg file
system.accessviolationexception when it writes a dwg file
when i upgrade my project from visual studio 2003 using dwgdirect 2.1 to visual studio 2008 sp1 using dwgdirect 2.7.1.0, i got the 'system.accessviolationexception' with additional information 'attempted to read or write protected memory. this is often an indication that other memory is corrupt'.
my codes to save the dwg file:
code:
odstaticrxobject<dwgservices> m_svcs;
odinitialize(&m_svcs);
oddbdatabaseptr m_database = m_svcs.createdatabase();
// ... add oddb3dsolidptr objects to the database.
odwrfilebuf filebuffer(m_filename);
m_database->writefile(&filebuffer, m_filetype, m_version, true);
filebuffer.close();it throws the exception in the writefile method. my codes are the same as the odwriteex sample, the only difference is i have cli (managed c++) dll calling the dwgdirect c++ classes, and the c# winform calls the methods from the cli dll. it also throws the system.accessviolationexception when i do not create any 3d objects to the database object (it means just creates the service object, create the database object, create the filebuffer object, then call writefile to save).
if the writefile sets savethumbnailimage to false as 'm_database->writefile(&filebuffer, m_filetype, m_version, false)' it does not throw the exception, but my dwg file does not save all the 3d solid objects correctly.
i figured out it fails to load the "winbitmap.gs" module in the code below, the pgsmodule is null. the exeption is "microsoft c++ exception: oderror_filenotfound at memory location 0x1075a6bc...". if i try to use the full path name for the "winbitmap.gs" such as loadmodule(l"c:\\dwg\\winbitmap.gs", false) i still got the same exception.
code:
#if !defined(_toolkit_in_dll_) || defined(__mwerks__)
odrx_declare_static_module_entry_point(modelermodule);
odrx_declare_static_module_entry_point(bitmapmodule);
odrx_begin_static_module_map()
odrx_define_static_application(l"modelergeometry", modelermodule)
odrx_define_static_appmodule (l"winbitmap.gs", bitmapmodule)
odrx_end_static_module_map()
#endif
class dwgservices : public exsystemservices, public exhostappservices
{
protected:
odrx_using_heap_operators(exsystemservices);
odgsdeviceptr gsbitmapdevice()
{
try
{
odgsmoduleptr pgsmodule = :

drxdynamiclinker()->loadmodule(l"winbitmap.gs", false);
return pgsmodule->createbitmapdevice();
}
catch(const oderror&)
{
}
return odgsdeviceptr();
}
};
any help is appreciated.
last edited by
hnguyen@inovx.com; 18th march 2009 at 06:01 pmfff">.