Solid Edge ST7 SDK
Connecting To Solid Edge

You may still use the familiar GetObject() method from the Visual Basic 6 days if you'd like. In Visual Basic .NET, GetObject() simply calls Marshal.GetActiveObject. This is important to understand because GetObject() is a language specific feature of Visual Basic .NET. No other .NET language has a comparable feature. The other .NET languages must rely on Marshal.GetActiveObject.

See Handling 'Application is Busy' and 'Call was Rejected By Callee' errors for information regarding the use of OleMessageFilter.
Connecting To Solid Edge from Visual Basic .NET
Copy Code
Imports System.Runtime.InteropServices

Module Program
    <STAThread()> _
    Sub Main()
        Dim objApplication As SolidEdgeFramework.Application = Nothing

        Try
            'Old VB6 Syntax
            'objApp = GetObject(, "SolidEdge.Application")

            OleMessageFilter.Register()

            ' Connect to a running instance of Solid Edge
            objApplication = Marshal.GetActiveObject("SolidEdge.Application")

        Catch ex As Exception
            Console.WriteLine(ex.Message)
        Finally
            OleMessageFilter.Revoke()
        End Try
    End Sub
End Module
Connecting To Solid Edge from C#
Copy Code
using Examples;
using System;
using System.Runtime.InteropServices;

namespace SolidEdge.SDK
{
    class Program
    {
        [STAThread]
        static void Main(string[] args)
        {
            SolidEdgeFramework.Application application = null;

            try
            {
                OleMessageFilter.Register();

                // Connect to a running instance of Solid Edge
                application = (SolidEdgeFramework.Application)
                    Marshal.GetActiveObject("SolidEdge.Application");
            }
            catch (System.Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            finally
            {
                OleMessageFilter.Revoke();
            }
        }
    }
}
See Also