AnsweredAssumed Answered

C# code issue in add in

Question asked by Josh Hixon on Aug 8, 2018
Latest reply on Aug 8, 2018 by Christian Chu

Okay, so I am pretty brand new to programming in C# I have gotten pretty good in, but the best tutorial I could find for creating a task pane add-in was in C#. I figured it was time to make the jump. I am learning on the fly, but am struggling with what should be a simple bit of code. Could someone point me in the right direction? Here is what I have.


using SolidWorks.Interop.sldworks;
using SolidWorks.Interop.swconst;
using System.Runtime.InteropServices;
using System.Windows.Forms;

namespace Template
    public partial class TaskpaneUI : UserControl
        public TaskpaneUI()

        private void TabPage2_Click(object sender, System.EventArgs e)


        private void Button1_Click(object sender, System.EventArgs e)
            ModelDoc2 doc;
            doc = swapp.OpenDoc(@"C:\SPECTRUM\spectrum aquatics\engineering\working folders\cole\1830238.sldprt", (int)swDocumentTypes_e.swDocPART);

            ModelDoc2 swmodel = (ModelDoc2)swapp.ActiveDoc;

            string pname = swmodel.GetPathName();

        public SldWorks swapp;

the error I keep getting is as follows:




Message was edited by: Josh Hixon