laros79 Posted December 19, 2008 Report Share Posted December 19, 2008 Dear All - I have a problem in 2 days not solve.. . the background: we want to save all stream chart into blob database column. I really appreciate your help. the situation is:when we are executing method RenderToStream in web projects, it's fine... ,but when i create library project C# to run method RenderToStream then showing error message: "Object reference not set to an instance of an object." the error stack trace is: at ChartFX.WebForms.Writer.Svg.SvgWriter.b(Stream A_0, OutputText A_1, OutputInfo A_2) at ChartFX.WebForms.Internal.OutputScript.b(Stream A_0, OutputText A_1, OutputInfo A_2) at ChartFX.WebForms.Chart.a(Stream A_0, IOutputWriter A_1, OutputText A_2, OutputText A_3, OutputInfo A_4) at ChartFX.WebForms.Chart.a(String A_0, Stream A_1, TextWriter A_2, TextWriter A_3) at ChartFX.WebForms.Chart.RenderToStream(Stream content, TextWriter imgMap, TextWriter htmlTag) below is snapshot code:Chart chart1 = new Chart(); chart1.ImageSettings.ToolTips = ImageToolTipStyle.AsTitle; chart1.ID = "SalesChart"; System.Text.StringBuilder strBuilder1 = new System.Text.StringBuilder(""); System.Text. StringBuilder strBuilder2 = new System.Text.StringBuilder("");System.IO.StringWriter strWriter1 = new System.IO.StringWriter(strBuilder1); System.IO. StringWriter strWriter2 = new System.IO.StringWriter(strBuilder1);System.IO.Stream svgStream = new System.IO.MemoryStream(); svgStream.Position = 0;chart1.OutputWriter = new ChartFX.WebForms.Writer.Svg.SvgWriter(); chart1.RenderToStream(svgStream, strWriter1, strWriter2); svgStream.Position = 0;System.Xml.XmlTextReader svgReader = new XmlTextReader(svgStream); svgReader.Namespaces = true;XmlDocument doc = new XmlDocument(); doc.Load(svgReader); XmlElement svgRoot = doc.DocumentElement; svgRoot.Attributes.RemoveNamedItem( "xml:space");XmlAttribute aspectAttr = doc.CreateAttribute("preserveAspectRatio");aspectAttr.Value = "none"; svgRoot.Attributes.Append(aspectAttr); svgStream.Close(); strWriter1.Close(); strWriter2.Close(); Quote Link to comment Share on other sites More sharing options...
Frank Posted December 19, 2008 Report Share Posted December 19, 2008 The writer is requiring HttpContext.Current in order to determine whether the browser supports ActiveX controls or not as the output is different depending on this. Since you are calling outside of ASP.NET, this context is null. Quote Link to comment Share on other sites More sharing options...
laros79 Posted December 21, 2008 Author Report Share Posted December 21, 2008 Thanks Frank, but when i did it on previosu version 6.0 (chartFX.Internet) .. it was good and works... is that any reason why it must need httpcontext.current whenever we don't need to check whether using ActiveX control or not. because if we export it into SVG. it should be processing SVG stream without check ActiveX in httpContext, right? do you have any idea to manipulate it? or should i go back using previuos version? again thanks Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.