Reply
Solved! Go to solution

Active Document Error in C#

I have this basic code in C# but it fails to set the active document and it error out.

it fails on this Line:

 

document = application.ActiveDocument();

 

ANy Help on properly getting the active document?

 

SolidEdgeFramework.Application application = null;

SolidEdgeDocument document = null;

SolidEdgeFramework.Variables variablesTable = null;

try

{

OleMessageFilter.Register();

// Connect to running Solid Edge Instance

application = (SolidEdgeFramework.Application)

Marshal.GetActiveObject("SolidEdge.Application");

document = application.ActiveDocument();

}

 

2 REPLIES
Solution
Solution
Accepted by topic author SergioH
‎08-26-2015 04:32 AM

Re: Active Document Error in C#

document = application.ActiveDocument;

 

I guess i just solved my own problem, it was only a matter of taking the parentisis out

Re: Active Document Error in C#

[ Edited ]

Bravo!

Parentheses are used with methods while properties do not need them.

VB is more forgiving in such cases. An extra pair of parentheses does no harm for properties.

Also leaving out the parentheses for methods with no arguments too is fine in VB.