I am attempting to connect to SolidWorks via this code:
Dim swApp As SolidWorks.Interop.sldworks.ISldWorks = _
TryCast(System.Runtime.InteropServices.Marshal.GetActiveObject("SldWorks.Application.34"), SolidWorks.Interop.sldworks.ISldWorks)
The connection works just fine and dandy when everything is fresh. It seems that if SolidWorks has been open overnight, this call fails with this exception:
Operation unavailable (Exception from HRESULT: 0x800401E3 (MK_E_UNAVAILABLE))
If I restart SolidWorks, everything begins working as expected.
Any ideas why this is throwing an error?
GetActiveObjectuses COM's Running Object Table (ROT). Next time you get theMK_E_UNAVAILABLEerror, use a tool (like these) to view the contents of the ROT, which should help you identify the problem.