几何尺寸与公差论坛

 找回密码
 注册
查看: 637|回复: 0

【转帖】microsoft visual c== runtime error

[复制链接]
发表于 2009-4-13 12:48:48 | 显示全部楼层 |阅读模式
microsoft visual c++ runtime error
hi,
i am using solidworks 2007 sp-1.0 software in my windows 2003 server. frequently i am facing an runtime exception while closing the open documents. we have developed an consle application in visual studio 2005 which will automate the solidworks application through the solidworks api.
after creating a tif image for the opened drawing, we are trying to close the drawing by using the closedoc method available in the isldworks class. following is the code what we have developed. i have included try catch block within the statements which causes this exception. after performing the appropriate steps, while closing the opened solid works document, this exception is thrown. after an user interaction (click on ok button) the exception is caught by the try catch block.
i am not sure what is causing this exception. pfa code snippet for your reference.
void swutilcunload(void)
{
// make sure the solidworks session was passed in
try
{
verifysw();
}
catch(cstring cserror)
{
cstring csmsg;
csmsg.format("docunload: %s",cserror);
throw csmsg;
}
try
{
// now unload each of the loaded documents.
m_model = pm_swapp->getactivedoc();
while ( m_model )
{
try
{
cstring csname = m_model.gettitle();
if ( csname.getlength() > 0 )
{
lflog.debugmsgstart(csname);
pm_swapp->closedoc( csname );
m_csmodelfilename.empty();
}
}
catch(...)
{
cstring cserror;
cserror.format("docunload: could not close the (%s)", m_csmodelfilename);
throw cserror;
}
try
{
if ( m_model)
{
m_model.releasedispatch();
m_model = 0;
}
}
catch(...)
{
cstring cserror;
cserror.format("docunload: could not release the model dispatch for model (%s)", m_csmodelfilename);
throw cserror;
}
// get next active document..if any.
m_model = pm_swapp->getactivedoc();
}
}
catch(...)
{
cstring cserror;
cserror.format("docunload: error while closing the m_model");
throw cserror;
}
//
// force back to invisible in case it was made visible by a bom check.
//
pm_swapp->setusercontrol(false);
pm_swapp->setvisible(false);
}
we are using the imodeldoc2->close() option to close the document. following is the exception thrown.
runtime error!
program
this application has requested the runtime to terminate it in an unusual way. please contact the applications support team for more information.
can any one please help me on this. your help is greatly appreciated !
edited: 07/01/2008 at 05:32 pm by madhavan mohanarangam
you are passing the model title in not the model path. use getpathname() instead.
您需要登录后才可以回帖 登录 | 注册

本版积分规则

QQ|Archiver|小黑屋|几何尺寸与公差论坛

GMT+8, 2024-12-23 14:38 , Processed in 0.036115 second(s), 19 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表