<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Form Button Object reference not set in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/form-button-object-reference-not-set/m-p/7294283#M30283</link>
    <description>&lt;P&gt;Please disregard my previous post I attached the original project not the &amp;nbsp;current one&amp;nbsp;&lt;/P&gt;&lt;P&gt;Current project attached to this post&lt;/P&gt;</description>
    <pubDate>Fri, 11 Aug 2017 16:06:26 GMT</pubDate>
    <dc:creator>ERGCONSULT</dc:creator>
    <dc:date>2017-08-11T16:06:26Z</dc:date>
    <item>
      <title>Form Button Object reference not set</title>
      <link>https://forums.autodesk.com/t5/net-forum/form-button-object-reference-not-set/m-p/7278921#M30278</link>
      <description>&lt;P&gt;I have&amp;nbsp;written some code to create a project file based on information on a form the original code was VB6 and sense I upgraded it to VB10 &amp;nbsp;when I click the cmdCreat button I get&lt;/P&gt;&lt;P&gt;System.NullReferenceException: Object reference not set to an instance of an object.&lt;BR /&gt;at CreateProjII.frmCreateProj.cmdCreate_Click(Object sender, EventArgs e)&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is the form code&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Option Explicit On&lt;/P&gt;&lt;P&gt;Imports Inventor&lt;BR /&gt;Imports System.Runtime.InteropServices&lt;BR /&gt;Imports Microsoft.Win32&lt;BR /&gt;Imports System&lt;BR /&gt;Imports System.IO&lt;BR /&gt;Imports System.Xml&lt;BR /&gt;Imports System.Xml.Linq&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Public Class frmCreateProj&lt;/P&gt;&lt;P&gt;Private Sub cmdCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdCancel.Click&lt;BR /&gt;Me.Close()&lt;BR /&gt;End Sub&lt;/P&gt;&lt;P&gt;Public Sub cmdCreate_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdCreate.Click&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Dim oApp As Inventor.Application&lt;BR /&gt;oApp = ThisApplication&lt;/P&gt;&lt;P&gt;Dim oDocs As Inventor.Documents&lt;BR /&gt;oDocs = oApp.Documents&lt;/P&gt;&lt;P&gt;Dim filename As String&lt;BR /&gt;If txtFileNum.Text = "" Then&lt;BR /&gt;filename = txtProj.Text &amp;amp; "_" &amp;amp; txtComp.Text&lt;BR /&gt;Else&lt;BR /&gt;filename = txtFileNum.Text&lt;BR /&gt;End If&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Dim IpjName As String&lt;BR /&gt;IpjName = txtIpjName.Text&lt;/P&gt;&lt;P&gt;Dim projnum As String&lt;BR /&gt;projnum = txtProj.Text&lt;/P&gt;&lt;P&gt;Dim compname As String&lt;BR /&gt;compname = txtComp.Text&lt;/P&gt;&lt;P&gt;Dim Title As String&lt;BR /&gt;Title = txtTitle.Text&lt;/P&gt;&lt;P&gt;Dim vendor As String&lt;BR /&gt;vendor = "Gerbcon"&lt;/P&gt;&lt;P&gt;'create project folders&lt;BR /&gt;My.Computer.FileSystem.CreateDirectory("H:\Current Engineering\" &amp;amp; filename)&lt;BR /&gt;My.Computer.FileSystem.CreateDirectory("H:\Current Engineering\" &amp;amp; filename &amp;amp; "\Templates")&lt;BR /&gt;My.Computer.FileSystem.CreateDirectory("H:\Current Engineering\" &amp;amp; filename &amp;amp; "\Content Center Files")&lt;BR /&gt;My.Computer.FileSystem.CreateDirectory("H:\Current Engineering\" &amp;amp; filename &amp;amp; "\Assemblies")&lt;BR /&gt;My.Computer.FileSystem.CreateDirectory("H:\Current Engineering\" &amp;amp; filename &amp;amp; "\Parts")&lt;BR /&gt;My.Computer.FileSystem.CreateDirectory("H:\Current Engineering\" &amp;amp; filename &amp;amp; "\Drawings")&lt;BR /&gt;My.Computer.FileSystem.CreateDirectory("H:\Current Engineering\" &amp;amp; filename &amp;amp; "\SentItems")&lt;BR /&gt;My.Computer.FileSystem.CreateDirectory("H:\Current Engineering\" &amp;amp; filename &amp;amp; "\Quotes")&lt;BR /&gt;My.Computer.FileSystem.CreateDirectory("H:\Current Engineering\" &amp;amp; filename &amp;amp; "\Imported components")&lt;BR /&gt;My.Computer.FileSystem.CreateDirectory("H:\Current Engineering\" &amp;amp; filename &amp;amp; "\Notes")&lt;BR /&gt;My.Computer.FileSystem.CreateDirectory("H:\Current Engineering\" &amp;amp; filename &amp;amp; "\Electrical")&lt;BR /&gt;My.Computer.FileSystem.CreateDirectory("H:\Current Engineering\" &amp;amp; filename &amp;amp; "\Drawings" \ " txtProj.txt-1")&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;'Copy the Iparts folder and rename it Standard Parts&lt;BR /&gt;My.Computer.FileSystem.CopyDirectory("C:\NewProject\Iparts2010", "H:\Current Engineering\" &amp;amp; filename &amp;amp; "\StandardParts")&lt;BR /&gt;My.Computer.FileSystem.CopyDirectory("C:\NewProject\BOM", "H:\Current Engineering\" &amp;amp; filename &amp;amp; "\BOMS")&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;'generate ProjInfo.xml inside Templates folder&lt;BR /&gt;Dim B As XElement = _&lt;BR /&gt;&amp;lt;Project&amp;gt;&lt;BR /&gt;&amp;lt;FileNumber&amp;gt;&amp;lt;%= filename %&amp;gt;&amp;lt;/FileNumber&amp;gt;&lt;BR /&gt;&amp;lt;SONumber&amp;gt;&amp;lt;%= projnum %&amp;gt;&amp;lt;/SONumber&amp;gt;&lt;BR /&gt;&amp;lt;Customer&amp;gt;&amp;lt;%= compname %&amp;gt;&amp;lt;/Customer&amp;gt;&lt;BR /&gt;&amp;lt;JobTitle&amp;gt;&amp;lt;%= Title %&amp;gt;&amp;lt;/JobTitle&amp;gt;&lt;BR /&gt;&amp;lt;/Project&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;B.Add(&amp;lt;AdditionalSOs&amp;gt;&lt;BR /&gt;&amp;lt;AddSO1&amp;gt;&amp;lt;%= projnum %&amp;gt;&amp;lt;/AddSO1&amp;gt;&lt;BR /&gt;&amp;lt;/AdditionalSOs&amp;gt;) 'create element to throw additional SO numbers into starting with current SO&lt;BR /&gt;B.Add(&amp;lt;AdditionalJobTitles&amp;gt;&lt;BR /&gt;&amp;lt;AddJobTitle1&amp;gt;&amp;lt;%= Title %&amp;gt;&amp;lt;/AddJobTitle1&amp;gt;&lt;BR /&gt;&amp;lt;/AdditionalJobTitles&amp;gt;) 'create element to throw additional Titles into starting with current title&lt;BR /&gt;B.Save("H:\Current Engineering\" &amp;amp; filename &amp;amp; "\Templates\ProjInfo.xml")&lt;/P&gt;&lt;P&gt;'Finally, copy and modify new .ipj file (project file)&lt;BR /&gt;My.Computer.FileSystem.CopyFile("C:\NewProject\Temp2017.ipj", "H:\Current Engineering\" &amp;amp; filename &amp;amp; "\" &amp;amp; IpjName &amp;amp; ".ipj")&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;MsgBox("PROJECT BUILD COMPLETE", vbOKOnly)&lt;BR /&gt;Me.Close()&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;End Sub&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;End Class&lt;/P&gt;</description>
      <pubDate>Sat, 05 Aug 2017 15:57:20 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/form-button-object-reference-not-set/m-p/7278921#M30278</guid>
      <dc:creator>ERGCONSULT</dc:creator>
      <dc:date>2017-08-05T15:57:20Z</dc:date>
    </item>
    <item>
      <title>Re: Form Button Object reference not set</title>
      <link>https://forums.autodesk.com/t5/net-forum/form-button-object-reference-not-set/m-p/7282720#M30279</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Hi there&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;When ever you see something like this - it means that the pertinent reference (in this case cmdCreat) is not pointing to an actual button/or object.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Where have you created the button? Where is your UI code? &lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;You need to instantiate the button somewhere in your code otherwise you will get the above error.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;e.g.&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;System.Windows.Forms.Button cmdCreat&amp;nbsp;&amp;nbsp;= new System.Windows.Forms.Button();&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 07 Aug 2017 23:38:30 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/form-button-object-reference-not-set/m-p/7282720#M30279</guid>
      <dc:creator>BKSpurgeon</dc:creator>
      <dc:date>2017-08-07T23:38:30Z</dc:date>
    </item>
    <item>
      <title>Re: Form Button Object reference not set</title>
      <link>https://forums.autodesk.com/t5/net-forum/form-button-object-reference-not-set/m-p/7289228#M30280</link>
      <description>&lt;P&gt;First off Thank you for taking the time to look at this,&lt;/P&gt;&lt;P&gt;There is nothing in the project&amp;nbsp;anywhere resembling your comments and I believe all the UI is located in the StandardAddInServer.vb which is attached.&lt;/P&gt;&lt;P&gt;My apologies if I am not clear I am fairly new at this and&amp;nbsp;I have only been maintaining the code for the past few years,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 10 Aug 2017 00:28:34 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/form-button-object-reference-not-set/m-p/7289228#M30280</guid>
      <dc:creator>ERGCONSULT</dc:creator>
      <dc:date>2017-08-10T00:28:34Z</dc:date>
    </item>
    <item>
      <title>Re: Form Button Object reference not set</title>
      <link>https://forums.autodesk.com/t5/net-forum/form-button-object-reference-not-set/m-p/7292212#M30281</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;@Anonymous wrote:&lt;BR /&gt;&lt;P&gt;First off Thank you for taking the time to look at this,&lt;/P&gt;&lt;P&gt;There is nothing in the project&amp;nbsp;anywhere resembling your comments and I believe all the UI is located in the StandardAddInServer.vb which is attached.&lt;/P&gt;&lt;P&gt;My apologies if I am not clear I am fairly new at this and&amp;nbsp;I have only been maintaining the code for the past few years,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Your button click event handler where the exception is being thrown references variables that appear nowhere in the code you posted.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You are expecting others here to tell you what's wrong with code that you didn't post.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Try running your code in the debugger and step through the code in the event handler to find out what variable has not been initialized.&lt;/P&gt;</description>
      <pubDate>Thu, 10 Aug 2017 22:46:03 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/form-button-object-reference-not-set/m-p/7292212#M30281</guid>
      <dc:creator>ActivistInvestor</dc:creator>
      <dc:date>2017-08-10T22:46:03Z</dc:date>
    </item>
    <item>
      <title>Re: Form Button Object reference not set</title>
      <link>https://forums.autodesk.com/t5/net-forum/form-button-object-reference-not-set/m-p/7294256#M30282</link>
      <description>&lt;P&gt;I have attached the complete project in the hopes that you can point out what is missing, Here is a how I went about creating this project, I created a new project using the &amp;nbsp;2018 wizard I then added the old cod and form to the project using the add existing item feature, I then modified the code to display the button on the UI to open the form, Which works fine. If I click the cancel button the form closes without error,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I hope this is more useful than my previous posts&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you in advance for taking the time to guide me&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 11 Aug 2017 16:00:00 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/form-button-object-reference-not-set/m-p/7294256#M30282</guid>
      <dc:creator>ERGCONSULT</dc:creator>
      <dc:date>2017-08-11T16:00:00Z</dc:date>
    </item>
    <item>
      <title>Re: Form Button Object reference not set</title>
      <link>https://forums.autodesk.com/t5/net-forum/form-button-object-reference-not-set/m-p/7294283#M30283</link>
      <description>&lt;P&gt;Please disregard my previous post I attached the original project not the &amp;nbsp;current one&amp;nbsp;&lt;/P&gt;&lt;P&gt;Current project attached to this post&lt;/P&gt;</description>
      <pubDate>Fri, 11 Aug 2017 16:06:26 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/form-button-object-reference-not-set/m-p/7294283#M30283</guid>
      <dc:creator>ERGCONSULT</dc:creator>
      <dc:date>2017-08-11T16:06:26Z</dc:date>
    </item>
    <item>
      <title>Re: Form Button Object reference not set</title>
      <link>https://forums.autodesk.com/t5/net-forum/form-button-object-reference-not-set/m-p/7295566#M30284</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;@Anonymous wrote:&lt;BR /&gt;&lt;P&gt;I have attached the complete project in the hopes that you can point out what is missing, Here is a how I went about creating this project, I created a new project using the &amp;nbsp;2018 wizard I then added the old cod and form to the project using the add existing item feature, I then modified the code to display the button on the UI to open the form, Which works fine. If I click the cancel button the form closes without error,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I hope this is more useful than my previous posts&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you in advance for taking the time to guide me&amp;nbsp;&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Your project is an Inventor plug-in. &amp;nbsp;This is the AutoCAD .NET programming forum.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;There is a forum for &lt;A href="https://forums.autodesk.com/t5/inventor-customization/bd-p/120" target="_blank"&gt;Inventor customization&lt;/A&gt;, which is where you should be seeking help.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regardless of what kind of project it is, to find out where the problem is, You have to&lt;/P&gt;&lt;P&gt;run the code&amp;nbsp;in the debugger. Ask in the above forum how to go about debugging&lt;/P&gt;&lt;P&gt;Inventor plug-ins, if you're not sure how to do that.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 12 Aug 2017 01:04:37 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/form-button-object-reference-not-set/m-p/7295566#M30284</guid>
      <dc:creator>ActivistInvestor</dc:creator>
      <dc:date>2017-08-12T01:04:37Z</dc:date>
    </item>
  </channel>
</rss>

