views:

1212

answers:

2

I am getting this error Invalid temp directory in chart handler configuration [c:\TempImageFiles\]. While running my code.

Intially I was getting No http handler was found for request type ‘GET’ error which I solved it by referring no http handler

But now I am getting the above error The details of the error are

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.IO.DirectoryNotFoundException: Invalid temp directory in chart handler configuration [c:\TempImageFiles\].

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

The stackTrace of this error

[DirectoryNotFoundException: Invalid temp directory in chart handler configuration [c:\TempImageFiles\].]
   System.Web.UI.DataVisualization.Charting.ChartHttpHandlerSettings.Inspect() +851
   System.Web.UI.DataVisualization.Charting.ChartHttpHandlerSettings.ParseParams(String parameters) +1759
   System.Web.UI.DataVisualization.Charting.ChartHttpHandlerSettings..ctor(String parameters) +619
   System.Web.UI.DataVisualization.Charting.ChartHttpHandler.InitializeParameters() +237
   System.Web.UI.DataVisualization.Charting.ChartHttpHandler.EnsureInitialized(Boolean hardCheck) +208
   System.Web.UI.DataVisualization.Charting.ChartHttpHandler.EnsureInstalled() +33
   System.Web.UI.DataVisualization.Charting.Chart.GetImageStorageMode() +57
   System.Web.UI.DataVisualization.Charting.Chart.Render(HtmlTextWriter writer) +257
   System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +144
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +583
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +91
   System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +410
   System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +118
   System.Web.UI.HtmlControls.HtmlForm.RenderChildren(HtmlTextWriter writer) +489
   System.Web.UI.HtmlControls.HtmlContainerControl.Render(HtmlTextWriter writer) +84
   System.Web.UI.HtmlControls.HtmlForm.Render(HtmlTextWriter output) +713
   System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +144
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +583
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +91
   System.Web.UI.HtmlControls.HtmlForm.RenderControl(HtmlTextWriter writer) +91
   System.Web.UI.Control.RenderChildrenInternal(HtmlTextWriter writer, ICollection children) +410
   System.Web.UI.Control.RenderChildren(HtmlTextWriter writer) +118
   System.Web.UI.Control.Render(HtmlTextWriter writer) +60
   System.Web.UI.Page.Render(HtmlTextWriter writer) +66
   System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +144
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer, ControlAdapter adapter) +583
   System.Web.UI.Control.RenderControl(HtmlTextWriter writer) +91
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +7761

Can anyone tell me how to solve this problem... Should i have to create a temporary directory manually or what should i do...


Hi smarx, I check it.. They asked me to change

From   
<add key="ChartImageHandler" value="storage=file;timeout=20;dir=c:\TempImageFiles\;" />

To
 <add key="ChartImageHandler" value="storage=file;timeout=20;" />

in web config file...

But I don't have this line in my web config

I have only this for defining chart

<add name="ChartImg" verb="*" path="ChartImg.axd" type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler,     System.Web.DataVisualization, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"  />
<add name="ReportViewer" verb="*" path="Reserved.ReportViewerWebControl.axd" type="Microsoft.Reporting.WebForms.HttpHandler,Microsoft.ReportViewer.WebForms, Version=9.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />

What should I do now....

A: 

Check out this answer on the Windows Azure forum: http://social.msdn.microsoft.com/Forums/en-US/MSWinWebChart/thread/92238582-9445-4d15-a5a7-5f24fd4bf646/.

smarx
A: 

Hi,

You need to use a temporary directory that is within the folder hierarchy of your web application. In Windows Azure, you don't have access to c:\TempImages, so that is not going to work.

I created a quick sample of ASP.Net Charts working in Windows Azure here: http://code.msdn.microsoft.com/azurecharts

You can still use file storage for the temporary images:

If you don't want to download the sample, here are the steps to get it working:

  1. In your Solution, create a folder (called TempImages, for example).
  2. Add a file (temp.txt, or whatever) to this folder. The dev tools don't seem to publish empty directories.
  3. Set the image location of your chart to: ImageLocation="~/TempImages/ChartPic_#SEQ(300,3)"
  4. Add the following to appSettings in your web.config:

    [add key="ChartImageHandler" value="Storage=file;Timeout=20;Url=~/tempImages/;"/]

  5. Make sure the following is in system.web/assemblies

    [add assembly="System.Web.DataVisualization, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/]

  6. Make sure the following is in system.web/httpHandlers: [add path="ChartImg.axd" verb="GET,HEAD" type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" validate="false"/]

  7. Make sure the following is in system.webServer/handlers [add name="ChartImageHandler" preCondition="integratedMode" verb="GET,HEAD" path="ChartImg.axd" type="System.Web.UI.DataVisualization.Charting.ChartHttpHandler, System.Web.DataVisualization, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/]

The code I uploaded to code.msdn.com should suffice as an example.

Dan