AnsweredAssumed Answered

C# Stand Alone - Get active SW App

Question asked by Alexander Klammer on Jan 22, 2018
Latest reply on Feb 4, 2019 by Peer Larson

Hi,

 

I just tried to create a Stand Alone Application.

 

However i tried to connect to my current Solidworks App.

 

With these two methods:

SldWorks swApp = (SldWorks)Activator.CreateInstance(Type.GetTypeFromProgID("SldWorks.Application"));

SldWorks swApp = (SldWorks)System.Runtime.InteropServices.Marshal.GetActiveObject("SldWorks.Application");

 

However i just was not able to get the first one going - when i tried to set swModel to the Active doc it always returned 0:

(swModel = (ModelDoc2)swApp.ActiveDoc;)

 

Any ideas what´s going wrong here?

 

The second one worked but "just" when both - the Stand Alone App and SolidWorks where running as Administrator.

I guess this is "normal" behaviour, but i´d like to make some stand alone applications for our engineers and running the stand alone app and solidworks as administrator won´t be possible because of user permissions.

 

Does anyone have a solution for that?

 

BR

Alex

Outcomes