I've used C# to develop SAP2000(structural analysis software) post-processing program in VS2017 Community IDE for months. However, things went wrong while someday I found my code was no longer able to connect with SAP2000 instance, though I didn't change anything.
From SAP2000 official documentation, users can get SAP2000 instance reference by this snippet:
cOAPI mySapObject = (cOAPI)System.Runtime.InteropServices.Marshal.GetActiveObject("CSI.SAP2000.API.SapObject");
and this is how I connect to SAP2000, too. But for some reason, my programs throw Invalid class string (Exception from HRESULT: 0x800401F3 (CO_E_CLASSSTRING))
exception. Seems they can't detect SAP2000 running object now.
I am confused because my programs still run well in other computers don't install Visual Studio or only install VS2013. But for other computers have VS2017, the same error occurs as well. I guess some setting had been overwritten during the updating of recent package.
I found this link and this talked about some elevated privilege facts which might relate to my problem. But the error still happened even I launched both SAP2000 and VS2017 as administrator.
Solved, I reinstalled my SAP2000.
User contributions licensed under CC BY-SA 3.0