Another cause for this problem can be because the application pool is set to 'Classic' mode. My handler was configured correctly, but I was getting the same error.
As soon as I switched the application pool to 'Integrated' mode. The chart control started working correctly.