C# Add-In TaskPane Button displays Windows Form, when Form Button pressed code does not execute, displays error

Hello,

I am have been able to add a task pane successfully into SolidWorks, however the windows form I call on with the taskpane, which has been created by a user control, appears but when the button is selected the code found in the Form5 button will not run and displays this error.  Does anyone know or have a solution to this error?

Thank you for your time and efforts in this matter!!!!!!!!!!

I have a user control cs file named SWTaskpaneHost.cs With code as follows

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Drawing;

using System.Data;

using System.Linq;

using System.Text;

using System.Windows.Forms;

using SolidWorks.Interop.sldworks;

using SolidWorks.Interop.swcommands;

using SolidWorks.Interop.swconst;

using SolidWorks.Interop.swpublished;

using SolidWorksTools;

using System.Runtime.InteropServices;

namespace RaceWork.V1._09192012

{

    [ComVisible(true)]

    [ProgId(SWTASKPANE_PROGID)]

    public partial class SWTaskpaneHost : UserControl

    {

       

        Form5 form5_BP = new Form5();

        public const string SWTASKPANE_PROGID = "RaceWork.SWTaskPane_SwAddin";

        public SWTaskpaneHost()

        {

            InitializeComponent();

        }

        private void button1_Click(object sender, EventArgs e)

        {

            form5_BP.Show();

        }

Form5.cs file as

using System;

using System.Collections.Generic;

using System.ComponentModel;

using System.Data;

using System.Drawing;

using System.Linq;

using System.Text;

using System.Windows.Forms;

using System.IO;

using System.Runtime.InteropServices;

using SldWorks;

using SwConst;

using System.Diagnostics;

namespace RaceWork.V1._09192012

{

    public partial class Form5 : Form

    {

        SldWorks.SldWorks swApp;

        ModelDoc2 swModel;

       

        public Form5()

        {

            InitializeComponent();

        }

        private void button1_Click(object sender, EventArgs e)

        {  

            ModelDoc2 swModel = default(ModelDoc2);

            ModelDocExtension swModelDocExt = default(ModelDocExtension);

            bool status = false;

           

            double F = 18;

            swModel = (ModelDoc2)swApp.ActiveDoc;

            swModelDocExt = (ModelDocExtension)swModel.Extension;

            //F

            status = swModelDocExt.SelectByID2("3DSketch3", "SKETCH", 0, 0, 0, true, 0, null, 0);

            status = swModelDocExt.SelectByID2("D2@3DSketch3", "DIMENSION", 0, 0, 0, true, 0, null, 0);

            Dimension swDimension1 = default(Dimension);

            swDimension1 = (Dimension)swModel.Parameter("D2@3DSketch3");

            swDimension1.SystemValue = F * 0.0254;

            swModel.ClearSelection2(true);

            status = swModel.EditRebuild3();

  

        }

    }

}

SolidworksApi macros