![]() |
【转帖】he object invoked has disconnected from its clients
?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 |
所有的时间均为北京时间。 现在的时间是 10:36 AM. |