Null Reference Exception

  • Thread starter Ganesh Palaniappan
  • Start date
G

Ganesh Palaniappan

We're getting following exception for the below piece of code. We're wondering how it is possible since we're having a null check for objGraphics and strokePen...





Exception: System.NullReferenceException: Object reference not set to an instance of an object



if (strokePen != null && objGraphics != null)

{

if (float.Parse(style["x1"])>=0 && float.Parse(style["y1"])>= 0 && float.Parse(style["x2"])>=0 && float.Parse(style["y2"])>=0 )

{

objGraphics.DrawLine(strokePen,

float.Parse(style["x1"]),

float.Parse(style["y1"]),

float.Parse(style["x2"]),

float.Parse(style["y2"]));

}

}



Stack Trace:



[NullReferenceException: Object reference not set to an instance of an object.] System.Drawing.SafeNativeMethods.GdipDrawLine(HandleRef graphics, HandleRef pen, Single x1, Single y1, Single x2, Single y2) +0 System.Drawing.Graphics.DrawLine(Pen pen, Single x1, Single y1, Single x2, Single y2) +121 Thomson.Financial.Thomlets.Datastream.Web.Core.SVGImage.Render(Graphics& objGraphics, XmlNode containerNode) in d:\economics\src\economics\datastream.web.core\svg\svgrenderer.cs:372 Thomson.Financial.Thomlets.Datastream.Web.Core.SVGImage.RenderSVG(Graphics& objGraphics, Int32 width, Int32 height) in d:\economics\src\economics\datastream.web.core\svg\svgrenderer.cs:178 Thomson.Financial.Thomlets.Datastream.Web.Core.SVGImage.Render(Int32 width, Int32 height) in d:\economics\src\economics\datastream.web.core\svg\svgrenderer.cs:148 Thomson.Financial.Thomlets.Datastream.Web.Core.PngRenderStream.Flush() in d:\economics\src\economics\datastream.web.core\svg\pngrenderstream.cs:73 System.IO.StreamWriter.Flush(Boolean flushStream, Boolean flushEncoder) +169 System.IO.StreamWriter.Flush() +12 System.Xml.XmlTextWriter.Flush() +7 System.Xml.XmlDocument.Save(Stream outStream) +76 Thomson.Financial.Thomlets.Datastream.Web.Core.ChartWriter.WritePngChart(XmlDocument chartXml, SimpleHttpResponse httpResponse, Int32 width, Int32 height) in d:\economics\src\economics\datastream.web.core\charting\chartwriter.cs:49 Thomson.Financial.Thomlets.Economics.Web.LineChartPNGRequest.GenerateChart() in d:\economics\src\economics\economics.web\linechartpngrequest.aspx.cs:87 Thomson.Financial.Thomlets.Economics.Web.LineChartPNGRequest.OnLoad(EventArgs e) in d:\economics\src\economics\economics.web\linechartpngrequest.aspx.cs:55 System.Web.UI.Control.LoadRecursive() +35 System.Web.UI.Page.ProcessRequestMain() +750

Version Information: Microsoft .NET Framework Version:1.1.4322.2032; ASP.NET Version:1.1.4322.2032
 
K

Kevin Spencer

That's a tough one. Have you tried putting in a breakpoint?

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Chicken Magician

A man, a plan, a canal.
a palindrome that has gone to s**t.


We're getting following exception for the below piece of code. We're
wondering how it is possible since we're having a null check for objGraphics
and strokePen...





Exception: System.NullReferenceException: Object reference not set to an
instance of an object



if (strokePen != null && objGraphics != null)

{

if (float.Parse(style["x1"])>=0 && float.Parse(style["y1"])>= 0 &&
float.Parse(style["x2"])>=0 && float.Parse(style["y2"])>=0 )

{

objGraphics.DrawLine(strokePen,

float.Parse(style["x1"]),

float.Parse(style["y1"]),

float.Parse(style["x2"]),

float.Parse(style["y2"]));

}

}



Stack Trace:



[NullReferenceException: Object reference not set to an instance of an
object.] System.Drawing.SafeNativeMethods.GdipDrawLine(HandleRef graphics,
HandleRef pen, Single x1, Single y1, Single x2, Single y2) +0
System.Drawing.Graphics.DrawLine(Pen pen, Single x1, Single y1, Single x2,
Single y2) +121
Thomson.Financial.Thomlets.Datastream.Web.Core.SVGImage.Render(Graphics&
objGraphics, XmlNode containerNode) in
d:\economics\src\economics\datastream.web.core\svg\svgrenderer.cs:372
Thomson.Financial.Thomlets.Datastream.Web.Core.SVGImage.RenderSVG(Graphics&
objGraphics, Int32 width, Int32 height) in
d:\economics\src\economics\datastream.web.core\svg\svgrenderer.cs:178
Thomson.Financial.Thomlets.Datastream.Web.Core.SVGImage.Render(Int32 width,
Int32 height) in
d:\economics\src\economics\datastream.web.core\svg\svgrenderer.cs:148
Thomson.Financial.Thomlets.Datastream.Web.Core.PngRenderStream.Flush() in
d:\economics\src\economics\datastream.web.core\svg\pngrenderstream.cs:73
System.IO.StreamWriter.Flush(Boolean flushStream, Boolean flushEncoder) +169
System.IO.StreamWriter.Flush() +12 System.Xml.XmlTextWriter.Flush() +7
System.Xml.XmlDocument.Save(Stream outStream) +76
Thomson.Financial.Thomlets.Datastream.Web.Core.ChartWriter.WritePngChart(XmlDocument
chartXml, SimpleHttpResponse httpResponse, Int32 width, Int32 height) in
d:\economics\src\economics\datastream.web.core\charting\chartwriter.cs:49
Thomson.Financial.Thomlets.Economics.Web.LineChartPNGRequest.GenerateChart()
in d:\economics\src\economics\economics.web\linechartpngrequest.aspx.cs:87
Thomson.Financial.Thomlets.Economics.Web.LineChartPNGRequest.OnLoad(EventArgs
e) in
d:\economics\src\economics\economics.web\linechartpngrequest.aspx.cs:55
System.Web.UI.Control.LoadRecursive() +35
System.Web.UI.Page.ProcessRequestMain() +750

Version Information: Microsoft .NET Framework Version:1.1.4322.2032; ASP.NET
Version:1.1.4322.2032
 
S

snt

Did you check the values of style["n"]?

Ganesh said:
We're getting following exception for the below piece of code. We're wondering how it is possible since we're having a null check for objGraphics and strokePen...





Exception: System.NullReferenceException: Object reference not set to an instance of an object



if (strokePen != null && objGraphics != null)

{

if (float.Parse(style["x1"])>=0 && float.Parse(style["y1"])>= 0 && float.Parse(style["x2"])>=0 && float.Parse(style["y2"])>=0 )

{

objGraphics.DrawLine(strokePen,

float.Parse(style["x1"]),

float.Parse(style["y1"]),

float.Parse(style["x2"]),

float.Parse(style["y2"]));

}

}



Stack Trace:



[NullReferenceException: Object reference not set to an instance of an object.] System.Drawing.SafeNativeMethods.GdipDrawLine(HandleRef graphics, HandleRef pen, Single x1, Single y1, Single x2, Single y2) +0 System.Drawing.Graphics.DrawLine(Pen pen, Single x1, Single y1, Single x2, Single y2) +121 Thomson.Financial.Thomlets.Datastream.Web.Core.SVGImage.Render(Graphics& objGraphics, XmlNode containerNode) in d:\economics\src\economics\datastream.web.core\svg\svgrenderer.cs:372 Thomson.Financial.Thomlets.Datastream.Web.Core.SVGImage.RenderSVG(Graphics& objGraphics, Int32 width, Int32 height) in d:\economics\src\economics\datastream.web.core\svg\svgrenderer.cs:178 Thomson.Financial.Thomlets.Datastream.Web.Core.SVGImage.Render(Int32 width, Int32 height) in d:\economics\src\economics\datastream.web.core\svg\svgrenderer.cs:148 Thomson.Financial.Thomlets.Datastream.Web.Core.PngRenderStream.Flush() in d:\economics\src\economics\datastream.web.core\svg\pngrenderstream.cs:73 System.IO.StreamWriter.Flush(Boolean flushStream, Boolean flushEncoder) +169 System.IO.StreamWriter.Flush() +12 System.Xml.XmlTextWriter.Flush() +7 System.Xml.XmlDocument.Save(Stream outStream) +76 Thomson.Financial.Thomlets.Datastream.Web.Core.ChartWriter.WritePngChart(XmlDocument chartXml, SimpleHttpResponse httpResponse, Int32 width, Int32 height) in d:\economics\src\economics\datastream.web.core\charting\chartwriter.cs:49 Thomson.Financial.Thomlets.Economics.Web.LineChartPNGRequest.GenerateChart() in d:\economics\src\economics\economics.web\linechartpngrequest.aspx.cs:87 Thomson.Financial.Thomlets.Economics.Web.LineChartPNGRequest.OnLoad(EventArgs e) in d:\economics\src\economics\economics.web\linechartpngrequest.aspx.cs:55 System.Web.UI.Control.LoadRecursive() +35 System.Web.UI.Page.ProcessRequestMain() +750

Version Information: Microsoft .NET Framework Version:1.1.4322.2032; ASP.NET Version:1.1.4322.2032



------=_NextPart_000_0008_01C6B66C.7CF39820
Content-Type: text/html; charset=iso-8859-1
Content-Transfer-Encoding: quoted-printable
X-Google-AttachSize: 9218

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2900.2912" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">We're&nbsp;getting following
exception for the below piece of code. We're wondering how it is possible since
we're having a null check for objGraphics and strokePen...</SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"><?xml:namespace prefix = o ns =
"urn:schemas-microsoft-com:eek:ffice:eek:ffice" /><o:p>&nbsp;</o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"><o:p></o:p></SPAN>&nbsp;</P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">Exception: </SPAN><SPAN
style="FONT-SIZE: 8.5pt; COLOR: black; FONT-FAMILY: Arial">System.NullReferenceException:
Object reference not set to an instance of an object<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><SPAN
style="FONT-SIZE: 8.5pt; COLOR: black; FONT-FAMILY: Arial"><o:p>&nbsp;</o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><SPAN
style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'">if</SPAN><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"> (strokePen != <SPAN
style="COLOR: blue">null</SPAN> &amp;&amp; objGraphics != <SPAN
style="COLOR: blue">null</SPAN>)<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">{<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt; TEXT-INDENT: 0.5in"><SPAN
style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier New'">if</SPAN><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"> (<SPAN
style="COLOR: blue">float</SPAN>.Parse(style["x1"])&gt;=0 &amp;&amp; <SPAN
style="COLOR: blue">float</SPAN>.Parse(style["y1"])&gt;= 0 &amp;&amp; <SPAN
style="COLOR: blue">float</SPAN>.Parse(style["x2"])&gt;=0 &amp;&amp; <SPAN
style="COLOR: blue">float</SPAN>.Parse(style["y2"])&gt;=0
)<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
{<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"><EM><STRONG>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
objGraphics.DrawLine(strokePen,<o:p></o:p></STRONG></EM></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<SPAN style="COLOR: blue">float</SPAN>.Parse(style["x1"]),<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<SPAN style="COLOR: blue">float</SPAN>.Parse(style["y1"]),<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<SPAN style="COLOR: blue">float</SPAN>.Parse(style["x2"]),<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<SPAN
style="COLOR: blue">float</SPAN>.Parse(style["y2"]));<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
}<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">}<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"><o:p>&nbsp;</o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">Stack
Trace:<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"><o:p>&nbsp;</o:p></SPAN></P><PRE><SPAN style="FONT-SIZE: 9pt; COLOR: black"><FONT face="Lucida Console">[NullReferenceException: Object reference not set to an instance of an object.]<o:p></o:p></FONT></SPAN></PRE><PRE><SPAN style="FONT-SIZE: 9pt; COLOR: black"><FONT face="Lucida Console">&nbsp;&nbsp; System.Drawing.SafeNativeMethods.GdipDrawLine(HandleRef graphics, HandleRef pen, Single x1, Single y1, Single x2, Single y2) +0<o:p></o:p></FONT></SPAN></PRE><PRE><SPAN style="FONT-SIZE: 9pt; COLOR: black"><FONT face="Lucida Console">&nbsp;&nbsp; System.Drawing.Graphics.DrawLine(Pen pen, Single x1, Single y1, Single x2, Single y2) +121<o:p></o:p></FONT></SPAN></PRE><PRE><SPAN style="FONT-SIZE: 9pt; COLOR: black"><FONT face="Lucida Console">&nbsp;&nbsp; Thomson.Financial.Thomlets.Datastream.Web.Core.SVGImage.Render(Graphics&amp; objGraphics, XmlNode containerNode) in d:\economics\src\economics\datastream.web.core\svg\svgrenderer.cs:372<o:p></o:p></FONT></SPAN></PRE><PRE><SPAN style="FONT-SIZE: 9pt; COLOR: black"><FONT face="Lucida Console">&nbsp;&nbsp; Thomson.Financial.Thomlets.Datastream.Web.Core.SVGImage.RenderSVG(Graphics&amp; objGraphics, Int32 width, Int32 height) in d:\economics\src\economics\datastream.web.core\svg\svgrenderer.cs:178<o:p></o:p></FONT></SPAN></PRE><PRE><SPAN style="FONT-SIZE: 9pt; COLOR: black"><FONT face="Lucida Console">&nbsp;&nbsp; Thomson.Financial.Thomlets.Datastream.Web.Core.SVGImage.Render(Int32 width, Int32 height) in d:\economics\src\economics\datastream.web.core\svg\svgrenderer.cs:148<o:p></o:p></FONT></SPAN></PRE><PRE><SPAN style="FONT-SIZE: 9pt; COLOR: black"><FONT face="Lucida Console">&nbsp;&nbsp; Thomson.Financial.Thomlets.Datastream.Web.Core.PngRenderStream.Flush() in d:\economics\src\economics\datastream.web.core\svg\pngrenderstream.cs:73<o:p></o:p></FONT></SPAN></PRE><PRE><SPAN style="FONT-SIZE: 9pt; COLOR: black"><FONT face="Lucida Console">&nbsp;&nbsp; System.IO.StreamWriter.Flush(Boolean flushStream, Boolean flushEncoder) +169<o:p></o:p></FONT></SPAN></PRE><PRE><SPAN style="FONT-SIZE: 9pt; COLOR: black"><FONT face="Lucida Console">&nbsp;&nbsp; System.IO.StreamWriter.Flush() +12<o:p></o:p></FONT></SPAN></PRE><PRE><SPAN style="FONT-SIZE: 9pt; COLOR: black"><FONT face="Lucida Console">&nbsp;&nbsp; System.Xml.XmlTextWriter.Flush() +7<o:p></o:p></FONT></SPAN></PRE><PRE><SPAN style="FONT-SIZE: 9pt; COLOR: black"><FONT face="Lucida Console">&nbsp;&nbsp; System.Xml.XmlDocument.Save(Stream outStream) +76<o:p></o:p></FONT></SPAN></PRE><PRE><SPAN style="FONT-SIZE: 9pt; COLOR: black"><FONT face="Lucida Console">&nbsp;&nbsp; Thomson.Financial.Thomlets.Datastream.Web.Core.ChartWriter.WritePngChart(XmlDocument chartXml, SimpleHttpResponse httpResponse, Int32 width, Int32 height) in d:\economics\src\economics\datastream.web.core\charting\chartwriter.cs:49<o:p></o:p></FONT></SPAN></PRE><PRE><SPAN style="FONT-SIZE: 9pt; COLOR: black"><FONT face="Lucida Console">&nbsp;&nbsp; Thomson.Financial.Thomlets.Economics.Web.LineChartPNGRequest.GenerateChart() in d:\economics\src\economics\economics.web\linechartpngrequest.aspx.cs:87<o:p></o:p></FONT></SPAN></PRE><PRE><SPAN style="FONT-SIZE: 9pt; COLOR: black"><FONT face="Lucida Console">&nbsp;&nbsp; Thomson.Financial.Thomlets.Economics.Web.LineChartPNGRequest.OnLoad(EventArgs e) in d:\economics\src\economics\economics.web\linechartpngrequest.aspx.cs:55<o:p></o:p></FONT></SPAN></PRE><PRE><SPAN style="FONT-SIZE: 9pt; COLOR: black"><FONT face="Lucida Console">&nbsp;&nbsp; System.Web.UI.Control.LoadRecursive() +35<o:p></o:p></FONT></SPAN></PRE><PRE><SPAN style="FONT-SIZE: 9pt; COLOR: black"><FONT face="Lucida Console">&nbsp;&nbsp; System.Web.UI.Page.ProcessRequestMain() +750<o:p></o:p></FONT></SPAN></PRE>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"><o:p>&nbsp;</o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><B><SPAN
style="FONT-SIZE: 8.5pt; COLOR: black; FONT-FAMILY: Verdana">Version
Information:</SPAN></B><SPAN
style="FONT-SIZE: 8.5pt; COLOR: black; FONT-FAMILY: Arial">&nbsp;Microsoft .NET
Framework Version:1.1.4322.2032; ASP.NET
Version:1.1.4322.2032</SPAN><o:p></o:p></P>
<P class=MsoNormal
style="MARGIN: 0in 0in 0pt"><o:p>&nbsp;</o:p></P></DIV></BODY></HTML>

------=_NextPart_000_0008_01C6B66C.7CF39820--
 
G

Ganesh Palaniappan

Yes - have checked values of style["n"] - no issues with that...

Thanks.

snt said:
Did you check the values of style["n"]?

Ganesh said:
We're getting following exception for the below piece of code. We're
wondering how it is possible since we're having a null check for
objGraphics and strokePen...





Exception: System.NullReferenceException: Object reference not set to an
instance of an object



if (strokePen != null && objGraphics != null)

{

if (float.Parse(style["x1"])>=0 && float.Parse(style["y1"])>= 0 &&
float.Parse(style["x2"])>=0 && float.Parse(style["y2"])>=0 )

{

objGraphics.DrawLine(strokePen,

float.Parse(style["x1"]),

float.Parse(style["y1"]),

float.Parse(style["x2"]),

float.Parse(style["y2"]));

}

}



Stack Trace:



[NullReferenceException: Object reference not set to an instance of an
object.] System.Drawing.SafeNativeMethods.GdipDrawLine(HandleRef
graphics, HandleRef pen, Single x1, Single y1, Single x2, Single y2) +0
System.Drawing.Graphics.DrawLine(Pen pen, Single x1, Single y1, Single
x2, Single y2) +121
Thomson.Financial.Thomlets.Datastream.Web.Core.SVGImage.Render(Graphics&
objGraphics, XmlNode containerNode) in
d:\economics\src\economics\datastream.web.core\svg\svgrenderer.cs:372
Thomson.Financial.Thomlets.Datastream.Web.Core.SVGImage.RenderSVG(Graphics&
objGraphics, Int32 width, Int32 height) in
d:\economics\src\economics\datastream.web.core\svg\svgrenderer.cs:178
Thomson.Financial.Thomlets.Datastream.Web.Core.SVGImage.Render(Int32
width, Int32 height) in
d:\economics\src\economics\datastream.web.core\svg\svgrenderer.cs:148
Thomson.Financial.Thomlets.Datastream.Web.Core.PngRenderStream.Flush() in
d:\economics\src\economics\datastream.web.core\svg\pngrenderstream.cs:73
System.IO.StreamWriter.Flush(Boolean flushStream, Boolean flushEncoder)
+169 System.IO.StreamWriter.Flush() +12
System.Xml.XmlTextWriter.Flush() +7 System.Xml.XmlDocument.Save(Stream
outStream) +76
Thomson.Financial.Thomlets.Datastream.Web.Core.ChartWriter.WritePngChart(XmlDocument
chartXml, SimpleHttpResponse httpResponse, Int32 width, Int32 height) in
d:\economics\src\economics\datastream.web.core\charting\chartwriter.cs:49
Thomson.Financial.Thomlets.Economics.Web.LineChartPNGRequest.GenerateChart()
in
d:\economics\src\economics\economics.web\linechartpngrequest.aspx.cs:87
Thomson.Financial.Thomlets.Economics.Web.LineChartPNGRequest.OnLoad(EventArgs
e) in
d:\economics\src\economics\economics.web\linechartpngrequest.aspx.cs:55
System.Web.UI.Control.LoadRecursive() +35
System.Web.UI.Page.ProcessRequestMain() +750

Version Information: Microsoft .NET Framework Version:1.1.4322.2032;
ASP.NET Version:1.1.4322.2032



------=_NextPart_000_0008_01C6B66C.7CF39820
Content-Type: text/html; charset=iso-8859-1
Content-Transfer-Encoding: quoted-printable
X-Google-AttachSize: 9218

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2900.2912" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">We're&nbsp;getting following
exception for the below piece of code. We're wondering how it is possible
since
we're having a null check for objGraphics and strokePen...</SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"><?xml:namespace prefix = o ns
=
"urn:schemas-microsoft-com:eek:ffice:eek:ffice" /><o:p>&nbsp;</o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: Arial"><o:p></o:p></SPAN>&nbsp;</P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: Arial">Exception: </SPAN><SPAN
style="FONT-SIZE: 8.5pt; COLOR: black; FONT-FAMILY:
Arial">System.NullReferenceException:
Object reference not set to an instance of an
object<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><SPAN
style="FONT-SIZE: 8.5pt; COLOR: black; FONT-FAMILY:
Arial"><o:p>&nbsp;</o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><SPAN
style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier
New'">if</SPAN><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"> (strokePen != <SPAN
style="COLOR: blue">null</SPAN> &amp;&amp; objGraphics != <SPAN
style="COLOR: blue">null</SPAN>)<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier
New'">{<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt; TEXT-INDENT: 0.5in"><SPAN
style="FONT-SIZE: 10pt; COLOR: blue; FONT-FAMILY: 'Courier
New'">if</SPAN><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'"> (<SPAN
style="COLOR: blue">float</SPAN>.Parse(style["x1"])&gt;=0 &amp;&amp;
<SPAN
style="COLOR: blue">float</SPAN>.Parse(style["y1"])&gt;= 0 &amp;&amp;
<SPAN
style="COLOR: blue">float</SPAN>.Parse(style["x2"])&gt;=0 &amp;&amp;
<SPAN
style="COLOR: blue">float</SPAN>.Parse(style["y2"])&gt;=0
)<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier
New'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
{<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier
New'"><EM><STRONG>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
objGraphics.DrawLine(strokePen,<o:p></o:p></STRONG></EM></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier
New'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<SPAN style="COLOR:
blue">float</SPAN>.Parse(style["x1"]),<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier
New'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<SPAN style="COLOR:
blue">float</SPAN>.Parse(style["y1"]),<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier
New'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<SPAN style="COLOR:
blue">float</SPAN>.Parse(style["x2"]),<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier
New'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
<SPAN
style="COLOR:
blue">float</SPAN>.Parse(style["y2"]));<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier
New'">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
}<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier
New'">}<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier
New'"><o:p>&nbsp;</o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier New'">Stack
Trace:<o:p></o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier
New'"><o:p>&nbsp;</o:p></SPAN></P><PRE><SPAN style="FONT-SIZE: 9pt;
COLOR: black"><FONT face="Lucida Console">[NullReferenceException: Object
reference not set to an instance of an
object.]<o:p></o:p></FONT></SPAN></PRE><PRE><SPAN style="FONT-SIZE: 9pt;
COLOR: black"><FONT face="Lucida Console">&nbsp;&nbsp;
System.Drawing.SafeNativeMethods.GdipDrawLine(HandleRef graphics,
HandleRef pen, Single x1, Single y1, Single x2, Single y2)
+0<o:p></o:p></FONT></SPAN></PRE><PRE><SPAN style="FONT-SIZE: 9pt; COLOR:
black"><FONT face="Lucida Console">&nbsp;&nbsp;
System.Drawing.Graphics.DrawLine(Pen pen, Single x1, Single y1, Single
x2, Single y2) +121<o:p></o:p></FONT></SPAN></PRE><PRE><SPAN
style="FONT-SIZE: 9pt; COLOR: black"><FONT face="Lucida
Console">&nbsp;&nbsp;
Thomson.Financial.Thomlets.Datastream.Web.Core.SVGImage.Render(Graphics&amp;
objGraphics, XmlNode containerNode) in
d:\economics\src\economics\datastream.web.core\svg\svgrenderer.cs:372<o:p></o:p></FONT></SPAN></PRE><PRE><SPAN
style="FONT-SIZE: 9pt; COLOR: black"><FONT face="Lucida
Console">&nbsp;&nbsp;
Thomson.Financial.Thomlets.Datastream.Web.Core.SVGImage.RenderSVG(Graphics&amp;
objGraphics, Int32 width, Int32 height) in
d:\economics\src\economics\datastream.web.core\svg\svgrenderer.cs:178<o:p></o:p></FONT></SPAN></PRE><PRE><SPAN
style="FONT-SIZE: 9pt; COLOR: black"><FONT face="Lucida
Console">&nbsp;&nbsp;
Thomson.Financial.Thomlets.Datastream.Web.Core.SVGImage.Render(Int32
width, Int32 height) in
d:\economics\src\economics\datastream.web.core\svg\svgrenderer.cs:148<o:p></o:p></FONT></SPAN></PRE><PRE><SPAN
style="FONT-SIZE: 9pt; COLOR: black"><FONT face="Lucida
Console">&nbsp;&nbsp;
Thomson.Financial.Thomlets.Datastream.Web.Core.PngRenderStream.Flush() in
d:\economics\src\economics\datastream.web.core\svg\pngrenderstream.cs:73<o:p></o:p></FONT></SPAN></PRE><PRE><SPAN
style="FONT-SIZE: 9pt; COLOR: black"><FONT face="Lucida
Console">&nbsp;&nbsp; System.IO.StreamWriter.Flush(Boolean flushStream,
Boolean flushEncoder) +169<o:p></o:p></FONT></SPAN></PRE><PRE><SPAN
style="FONT-SIZE: 9pt; COLOR: black"><FONT face="Lucida
Console">&nbsp;&nbsp; System.IO.StreamWriter.Flush()
+12<o:p></o:p></FONT></SPAN></PRE><PRE><SPAN style="FONT-SIZE: 9pt;
COLOR: black"><FONT face="Lucida Console">&nbsp;&nbsp;
System.Xml.XmlTextWriter.Flush()
+7<o:p></o:p></FONT></SPAN></PRE><PRE><SPAN style="FONT-SIZE: 9pt; COLOR:
black"><FONT face="Lucida Console">&nbsp;&nbsp;
System.Xml.XmlDocument.Save(Stream outStream)
+76<o:p></o:p></FONT></SPAN></PRE><PRE><SPAN style="FONT-SIZE: 9pt;
COLOR: black"><FONT face="Lucida Console">&nbsp;&nbsp;
Thomson.Financial.Thomlets.Datastream.Web.Core.ChartWriter.WritePngChart(XmlDocument
chartXml, SimpleHttpResponse httpResponse, Int32 width, Int32 height) in
d:\economics\src\economics\datastream.web.core\charting\chartwriter.cs:49<o:p></o:p></FONT></SPAN></PRE><PRE><SPAN
style="FONT-SIZE: 9pt; COLOR: black"><FONT face="Lucida
Console">&nbsp;&nbsp;
Thomson.Financial.Thomlets.Economics.Web.LineChartPNGRequest.GenerateChart()
in
d:\economics\src\economics\economics.web\linechartpngrequest.aspx.cs:87<o:p></o:p></FONT></SPAN></PRE><PRE><SPAN
style="FONT-SIZE: 9pt; COLOR: black"><FONT face="Lucida
Console">&nbsp;&nbsp;
Thomson.Financial.Thomlets.Economics.Web.LineChartPNGRequest.OnLoad(EventArgs
e) in
d:\economics\src\economics\economics.web\linechartpngrequest.aspx.cs:55<o:p></o:p></FONT></SPAN></PRE><PRE><SPAN
style="FONT-SIZE: 9pt; COLOR: black"><FONT face="Lucida
Console">&nbsp;&nbsp; System.Web.UI.Control.LoadRecursive()
+35<o:p></o:p></FONT></SPAN></PRE><PRE><SPAN style="FONT-SIZE: 9pt;
COLOR: black"><FONT face="Lucida Console">&nbsp;&nbsp;
System.Web.UI.Page.ProcessRequestMain()
+750<o:p></o:p></FONT></SPAN></PRE>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><SPAN
style="FONT-SIZE: 10pt; FONT-FAMILY: 'Courier
New'"><o:p>&nbsp;</o:p></SPAN></P>
<P class=MsoNormal style="MARGIN: 0in 0in 0pt"><B><SPAN
style="FONT-SIZE: 8.5pt; COLOR: black; FONT-FAMILY: Verdana">Version
Information:</SPAN></B><SPAN
style="FONT-SIZE: 8.5pt; COLOR: black; FONT-FAMILY:
Arial">&nbsp;Microsoft .NET
Framework Version:1.1.4322.2032; ASP.NET
Version:1.1.4322.2032</SPAN><o:p></o:p></P>
<P class=MsoNormal
style="MARGIN: 0in 0in 0pt"><o:p>&nbsp;</o:p></P></DIV></BODY></HTML>

------=_NextPart_000_0008_01C6B66C.7CF39820--
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,994
Messages
2,570,223
Members
46,810
Latest member
Kassie0918

Latest Threads

Top