Hello,
I am trying to render Line Chart on Windows Server 2003 environment which is my staging box. My chart is the aspx page which is in this folder D:\inetpub\wwwroot\bizcase30\rev\revcahrt.aspx. I also have ChartImages directory under rev folder.
This directory has Full Control on Network Service account and Full Control on ASPNET machine account. But yet when I try to render the graph I get the "A generic error occured in GDI+"My deployment scenario is File System. It is asking me to refer to KB article 5444.
The application bizcase30 runs part of a apppool. In the AppPool the property for Identity is set to Predefined - Network Service.
On my development box it renders properly since it is a XP box and the ASPNET machine account has fullcontrol on ChartImages folder.
Please help.
Thanks,
sorry for the delayed response, I just got back from a business trip & vacation.
try simplifying the problem by removing the chart and saving a normal image:
System.Drawing.Font arial = new System.Drawing.Font("Arial", 12f, System.Drawing.FontStyle.Bold); System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(250, 250); System.Drawing.Graphics gfx = System.Drawing.Graphics.FromImage(bmp); gfx.Clear(System.Drawing.Color.White); gfx.DrawString("Hello World", arial, System.Drawing.Brushes.Black, System.Drawing.PointF.Empty); bmp.Save(@"C:\test.png", System.Drawing.Imaging.ImageFormat.Png);
you can replace the path C:\test.png with the desired location of chart images. does an exception still occur?
Sorry, could not test your solution earlier. I did code according to your suggestion to generate the Test.png image. It threw the same error.
Your code did work on my development box which is a XP box. The staging box is a Windows Server 2003. It does not work on that box.
so there is an issue writing a file to that folder. are you sure the web app is running under the network service identity? are you sure that identity has write permissions on the ChartImages folder?
Yes. The Network Service identity has Full Control over the application and the ChartImages folder.
to confirm that your web app is running under the Network Service identity, try evaluating these expressions at runtime:
Page.User.Identity.NameSystem.Security.Principal.WindowsIdentity.GetCurrent().NameSystem.Threading.Thread.CurrentPrincipal.Identity.Name
Page.User.Identity.Name - Nothing (blank)
System.Security.Principal.WindowsIdentity.GetCurrent().Name - NT AUTHORITY\NETWORK SERVICE
System.Threading.Thread.CurrentPrincipal.Identity.Name - blank
at first i wondered why two of those came out blank, but when i tested this out in Server2003 i got the same result.
so i created a website on the server at http://localhost/website and c:\inetpub\wwwroot\WebSite.
then i created a subfolder called chartImages.
then I added this code to Page_Load:
System.Drawing.Font arial = new System.Drawing.Font("Arial", 12f, System.Drawing.FontStyle.Bold); System.Drawing.Bitmap bmp = new System.Drawing.Bitmap(250, 250); System.Drawing.Graphics gfx = System.Drawing.Graphics.FromImage(bmp); gfx.Clear(System.Drawing.Color.White); gfx.DrawString("Hello World", arial, System.Drawing.Brushes.Black, System.Drawing.PointF.Empty); bmp.Save(@"c:\inetpub\wwwroot\WebSite\chartImages\test.png", System.Drawing.Imaging.ImageFormat.Png);
at first, it didn't work, so i went to windows explorer, right-clicked the chart images folder, and on the security tab i added "Network Service" with Full control.
when i ran it again, the image was created, no problem.
i'm running out of ideas as to why this doesn't work on your server...
Finally I got it working. I deleted the application folder under wwwroot and the application from IIS. Recreated both, granted Network service Full Control access and it started working. Don't know what was wrong.
Anycase, thanks for your help.