Deploying ASP.NET MVC applications that use the Microsoft ASP.NET Charting control
Posted: (EET/GMT+2)
Recently, I've been working in many ASP.NET MVC development projects, and I must say I enjoy working with the technology, especially now that ASP.NET MVC 2 is available (though v1.0 wasn't bad, on the contrary).
If you have reporting needs in your MVC applications and want to show graphics/charts, then I can suggest using the Microsoft Charting Control, available for Windows Forms (WinForms) and ASP.NET 3.5. However, if you use this charting control in your MVC applications, everything might work nicely on your development machine (for instance, a Windows 7 box) but fail mysteriously on a server system.
For instance, you might get an error saying "A generic error occurred in GDI+" which is not at all helpful. However, the fact that the code happily works on your development system and fails on the production environment might lead you to think that something is missing. Personally, I haven't checked which GDI+ package installation would solve the problem, but there's a very quick remedy to this in code: simply don't save the generated image to the Response.OutputStream directly, but instead use a intermediate System.IO.MemoryStream first, and then write that MemoryStream to Response.OutputStream. After this, the problem should go away.
Of course, other problems in your application might also generate this same error, but given the way this error occurs, I suggest testing this idea first. If this tip does not help, then check what else might be missing from your deployment.