<?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 null reference could result in .NET Forum</title>
    <link>https://forums.autodesk.com/t5/net-forum/null-reference-could-result/m-p/2662460#M66009</link>
    <description>I know some people don't like to see questions here that include any com &lt;BR /&gt;
interop elements, but this is a dotnet question so does not belong in the &lt;BR /&gt;
vba group.&lt;BR /&gt;
acad2009 vbnet 2008 express&lt;BR /&gt;
how to avoid the compiler warning:&lt;BR /&gt;
Variable 'ArrayObjects' is used before it has been assigned a value. A null &lt;BR /&gt;
reference exception could result at runtime.&lt;BR /&gt;
&lt;BR /&gt;
given&lt;BR /&gt;
Dim ArrayObjects() As AcadEntity&lt;BR /&gt;
&lt;BR /&gt;
...some code...&lt;BR /&gt;
&lt;BR /&gt;
Try&lt;BR /&gt;
&lt;BR /&gt;
ReDim ArrayObjects(0)&lt;BR /&gt;
&lt;BR /&gt;
ArrayObjects(UBound(ArrayObjects)) = oSideLine&lt;BR /&gt;
&lt;BR /&gt;
Catch ex As ApplicationException&lt;BR /&gt;
&lt;BR /&gt;
m_Util.Logentry("error " &amp;amp; ex.Message)&lt;BR /&gt;
&lt;BR /&gt;
End Try&lt;BR /&gt;
&lt;BR /&gt;
...more code...then...&lt;BR /&gt;
&lt;BR /&gt;
Try&lt;BR /&gt;
&lt;BR /&gt;
If ArrayObjects Is Nothing Then &amp;lt;------------here is the warning location at &lt;BR /&gt;
"ArrayObjects"&lt;BR /&gt;
&lt;BR /&gt;
m_Util.Logentry("error ArrayObjects Is Nothing")&lt;BR /&gt;
&lt;BR /&gt;
Else&lt;BR /&gt;
&lt;BR /&gt;
SelectionSetWblock.AddItems(ArrayObjects)&lt;BR /&gt;
&lt;BR /&gt;
End If&lt;BR /&gt;
&lt;BR /&gt;
Catch ex As ApplicationException&lt;BR /&gt;
&lt;BR /&gt;
End Try&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
what should I be doing in such cases (using an array)&lt;BR /&gt;
&lt;BR /&gt;
i wouldn't think you'd do Dim ArrayObjects() As AcadEntity = Nothing&lt;BR /&gt;
&lt;BR /&gt;
like you might with a simple object???&lt;BR /&gt;
&lt;BR /&gt;
thanks&lt;BR /&gt;
&lt;BR /&gt;
mark</description>
    <pubDate>Wed, 07 Apr 2010 18:21:58 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2010-04-07T18:21:58Z</dc:date>
    <item>
      <title>null reference could result</title>
      <link>https://forums.autodesk.com/t5/net-forum/null-reference-could-result/m-p/2662460#M66009</link>
      <description>I know some people don't like to see questions here that include any com &lt;BR /&gt;
interop elements, but this is a dotnet question so does not belong in the &lt;BR /&gt;
vba group.&lt;BR /&gt;
acad2009 vbnet 2008 express&lt;BR /&gt;
how to avoid the compiler warning:&lt;BR /&gt;
Variable 'ArrayObjects' is used before it has been assigned a value. A null &lt;BR /&gt;
reference exception could result at runtime.&lt;BR /&gt;
&lt;BR /&gt;
given&lt;BR /&gt;
Dim ArrayObjects() As AcadEntity&lt;BR /&gt;
&lt;BR /&gt;
...some code...&lt;BR /&gt;
&lt;BR /&gt;
Try&lt;BR /&gt;
&lt;BR /&gt;
ReDim ArrayObjects(0)&lt;BR /&gt;
&lt;BR /&gt;
ArrayObjects(UBound(ArrayObjects)) = oSideLine&lt;BR /&gt;
&lt;BR /&gt;
Catch ex As ApplicationException&lt;BR /&gt;
&lt;BR /&gt;
m_Util.Logentry("error " &amp;amp; ex.Message)&lt;BR /&gt;
&lt;BR /&gt;
End Try&lt;BR /&gt;
&lt;BR /&gt;
...more code...then...&lt;BR /&gt;
&lt;BR /&gt;
Try&lt;BR /&gt;
&lt;BR /&gt;
If ArrayObjects Is Nothing Then &amp;lt;------------here is the warning location at &lt;BR /&gt;
"ArrayObjects"&lt;BR /&gt;
&lt;BR /&gt;
m_Util.Logentry("error ArrayObjects Is Nothing")&lt;BR /&gt;
&lt;BR /&gt;
Else&lt;BR /&gt;
&lt;BR /&gt;
SelectionSetWblock.AddItems(ArrayObjects)&lt;BR /&gt;
&lt;BR /&gt;
End If&lt;BR /&gt;
&lt;BR /&gt;
Catch ex As ApplicationException&lt;BR /&gt;
&lt;BR /&gt;
End Try&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
what should I be doing in such cases (using an array)&lt;BR /&gt;
&lt;BR /&gt;
i wouldn't think you'd do Dim ArrayObjects() As AcadEntity = Nothing&lt;BR /&gt;
&lt;BR /&gt;
like you might with a simple object???&lt;BR /&gt;
&lt;BR /&gt;
thanks&lt;BR /&gt;
&lt;BR /&gt;
mark</description>
      <pubDate>Wed, 07 Apr 2010 18:21:58 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/null-reference-could-result/m-p/2662460#M66009</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2010-04-07T18:21:58Z</dc:date>
    </item>
    <item>
      <title>Re: null reference could result</title>
      <link>https://forums.autodesk.com/t5/net-forum/null-reference-could-result/m-p/2662461#M66010</link>
      <description>A 'dotnet question' will probably get more answers on&lt;BR /&gt;
the relevant Microsoft newsgroups.&lt;BR /&gt;
&lt;BR /&gt;
This isn't a quesiton about using the managed .NET API,&lt;BR /&gt;
it is a basic VB.NET language usage question.&lt;BR /&gt;
&lt;BR /&gt;
I'm sure someone here that's more familiar with VB.NET&lt;BR /&gt;
will answer you, but I generally don't answer basic language&lt;BR /&gt;
usage questions here, because this really isn't the VB.NET&lt;BR /&gt;
(or C#) language newsgroup, this newsgroup is about using&lt;BR /&gt;
the managed AutoCAD API.&lt;BR /&gt;
&lt;BR /&gt;
-- &lt;BR /&gt;
http://www.caddzone.com&lt;BR /&gt;
&lt;BR /&gt;
AcadXTabs: MDI Document Tabs for AutoCAD&lt;BR /&gt;
Supporting AutoCAD 2000 through 2011&lt;BR /&gt;
&lt;BR /&gt;
http://www.acadxtabs.com&lt;BR /&gt;
&lt;BR /&gt;
Email: string.Format("{0}@{1}.com", "tonyt", "caddzone");&lt;BR /&gt;
&lt;BR /&gt;
"mp" &lt;NOSPAM&gt; wrote in message &lt;BR /&gt;
news:6368878@discussion.autodesk.com...&lt;BR /&gt;
I know some people don't like to see questions here that include any com&lt;BR /&gt;
interop elements, but this is a dotnet question so does not belong in the&lt;BR /&gt;
vba group.&lt;BR /&gt;
acad2009 vbnet 2008 express&lt;BR /&gt;
how to avoid the compiler warning:&lt;BR /&gt;
Variable 'ArrayObjects' is used before it has been assigned a value. A null&lt;BR /&gt;
reference exception could result at runtime.&lt;BR /&gt;
&lt;BR /&gt;
given&lt;BR /&gt;
Dim ArrayObjects() As AcadEntity&lt;BR /&gt;
&lt;BR /&gt;
...some code...&lt;BR /&gt;
&lt;BR /&gt;
Try&lt;BR /&gt;
&lt;BR /&gt;
ReDim ArrayObjects(0)&lt;BR /&gt;
&lt;BR /&gt;
ArrayObjects(UBound(ArrayObjects)) = oSideLine&lt;BR /&gt;
&lt;BR /&gt;
Catch ex As ApplicationException&lt;BR /&gt;
&lt;BR /&gt;
m_Util.Logentry("error " &amp;amp; ex.Message)&lt;BR /&gt;
&lt;BR /&gt;
End Try&lt;BR /&gt;
&lt;BR /&gt;
...more code...then...&lt;BR /&gt;
&lt;BR /&gt;
Try&lt;BR /&gt;
&lt;BR /&gt;
If ArrayObjects Is Nothing Then &amp;lt;------------here is the warning location at&lt;BR /&gt;
"ArrayObjects"&lt;BR /&gt;
&lt;BR /&gt;
m_Util.Logentry("error ArrayObjects Is Nothing")&lt;BR /&gt;
&lt;BR /&gt;
Else&lt;BR /&gt;
&lt;BR /&gt;
SelectionSetWblock.AddItems(ArrayObjects)&lt;BR /&gt;
&lt;BR /&gt;
End If&lt;BR /&gt;
&lt;BR /&gt;
Catch ex As ApplicationException&lt;BR /&gt;
&lt;BR /&gt;
End Try&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
&lt;BR /&gt;
what should I be doing in such cases (using an array)&lt;BR /&gt;
&lt;BR /&gt;
i wouldn't think you'd do Dim ArrayObjects() As AcadEntity = Nothing&lt;BR /&gt;
&lt;BR /&gt;
like you might with a simple object???&lt;BR /&gt;
&lt;BR /&gt;
thanks&lt;BR /&gt;
&lt;BR /&gt;
mark&lt;/NOSPAM&gt;</description>
      <pubDate>Wed, 07 Apr 2010 18:34:54 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/net-forum/null-reference-could-result/m-p/2662461#M66010</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2010-04-07T18:34:54Z</dc:date>
    </item>
  </channel>
</rss>

