This is in a unit test. My code to start the app in the TestInitialize method:
var progId = "SldWorks.Application";
var progType = System.Type.GetTypeFromProgID(progId);
app = System.Activator.CreateInstance(progType) as ISldWorks;
Solidworks starts just fine, I can see it start. When I test my method I am trying to get the currently running SolidWorks in the constructor I get the error on the last line:
string progId = "SldWorks.Application";
solidWorksApp = System.Runtime.InteropServices.Marshal.GetActiveObject(progId) as ISldWorks;
Searching for the error see a lot of the help says this is because Microsoft Office cant start. Solidworks DOES use Office in some functions but SolidWorks starts just fine.
I tried
Thread.Sleep(5000);
After I start SolidWorks but that did not help. I thought perhaps Solidworks wasn't completely started when I am trying to get the running instance.
There is already an add in running inside SolidWorks that uses the same technique to use the running SolidWorks app. I disabled the add in to test to see if perhaps only one at a time could connect. That did not resolve the issue.
Aucun commentaire:
Enregistrer un commentaire