Well, in my adventures I ran into a bug, not sure if it’s a bug or not, not sure how I even generated it or what code causes it, though it’s some kind of bug or something or other.
I built a custom PrintView using the printdoucment class which we all know is just a wrapper around the COM object. Why has MS not dedicated enough resources in getting rid of the COM’s? They are like some disease that won’t go away!
I built my PrintDocument so that it could read an XML file and get the datasource and build a report, but guess what? I kept getting this error "InteropServices.SEHException: External component has thrown an exception", it seems that if I add “Application.EnableVisualStyles()” to my Main Sub routine in my application and then tried to use my component, I would get this very nice and extremely useful error. Granted I built a form in the background, populated it with controls and then used databinding to navigate between sets of records and then steal all the paints of each control to paint my report. Never mind that, but having that EnableVisualStyles only messed up my whole solution. Never mind it was almost impossible to find, only until I started looking for something non-print related that I found this:
http://blogs.msdn.com/asanto/archive/2004/08/18/216825.aspx
So, take out that line and boom my report reader works like a charm, I suspect that what happened was it was trying to use the visualstyles on my controls and got turned around somewhere and decided to give my live hell. Those good for nothing COMS!!
Anyways, since I found little to no info, I figured to write this, so keep it safe when using the print controls/components.
Does anyone know why they are still COM wrappers in 2005? It’s just insane if you ask me, though maybe that will change one day.
To all a good night and happy Forth of July!!!