几何尺寸与公差论坛

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

【转帖】he object invoked has disconnected from its clients

[复制链接]
发表于 2009-4-12 22:38:23 | 显示全部楼层 |阅读模式
?the object invoked has disconnected from its clients?.
we have a add-in module build with visual basic .net 2008, and are using it with sw 2009 64bit on winxp 64 bit.
our users keep getting the "the object invoked has disconnected from its clients?. (?exception from ?hresult?: ?0?x?80010108 ?(?rpc_e_disconnected?))" error.
it is hard to pin down because it does not occur all the time and does not occur in the same spot in the code. it appears to happen randomly.
is there any way to prevent this from happening?
is there any way to detect this situation?
is there any way to recover once this happens in the application?
below is some example code that sometimes produces the error(not always).
public function renamecomp(byval oldname as string, byval newname as string, optional byval swapplication as sldworks.sldworks = nothing) as string
try
if isnothing(swapplication) = true then swapplication = swapp
'select the comp by its old name
dim swmodel as sldworks.modeldoc2
swmodel = swapp.iactivedoc2
if swmodel is nothing then
throw new exception("active document is nothing. cannot select cabinet")
end if
dim cname(0) as string
cname(0) = oldname
selectcomponents(cname, false, swapp)
dim selmgr as sldworks.selectionmgr
selmgr = swmodel.selectionmanager()
dim selcomp as sldworks.component2 = selmgr.getselectedobject6(1, -1)
if selcomp is nothing then
dim this as new exception("could not select cabinet")
throw this
end if
'change the name to the new name
swapp.setuserpreferencetoggle(swconst.swuserpreferencetoggle_e.swextrefupdatecompnames, false)
selcomp.name2 = newname
return selcomp.name2
catch ex as exception
throw new exception("failed renamecomp. oldname[" & oldname & "] newname[" & newname & "]" & ex.message)
end try
end function
what line does the error occur at?
the rpc disconnected error means that the pointer to the com object is no longer valid, usually a modeldoc2 object that no longer exists (model closed) or a solidworks variable that has been lost (solidworks closed or error in solidworks com functionality, try re-installing sw).
i'm not sure if it occurs on any one line or not, since i can't replicate the problem on demand.
the problem occurs on all our workstations, and all those were just recently built, so i don't think a reinstall would help.
i'm not familiar with the inner workings of com. are there any 'gotchas' or things i could check my code for to prevent com related problems?
if you want to email me your code i will find the bug for you. contact@angelsix.com
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-12-23 18:53 , Processed in 0.034754 second(s), 19 queries .

Powered by Discuz! X3.4 Licensed

© 2001-2023 Discuz! Team.

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