AnsweredAssumed Answered

create and connect with "exe" C#

Question asked by Oleg Bezyaev on Feb 21, 2011
Latest reply on Jun 12, 2011 by Oleg Bezyaev

Can anyone past code here to create the executable file, which can be connected without errors to solidworks? Just Form-Button.

public partial class Form1 : Form
    {
        SldWorks.SldWorks   swApp;
        ModelDoc2           swModel;

        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                swApp = (SldWorks.SldWorks)Marshal.GetActiveObject("SldWorks.Application");
            }
            catch
            {
                MessageBox.Show("Error getting SolidWorks Handle");
                return;

This code allways show

"Error getting SolidWorks Handle"

And what difference will be if libraries .NET or COM are connected?

Outcomes