views:

28

answers:

1

In the static void Main() of my winforms app I get the following exception:

"Unable to cast object of type 'Microsoft.VisualStudio.HostingProcess.ParkingWindow' to type 'CSVImport.frmImport'."

This happened afte moving some functionality out to a public class. I build to framework 3.5.

Here is the kicker: When I start the app by stepping with f10, no exception occurs!

edit: If I start the process with a single F10 press and then F5, all is happiness.

A: 

Solved it: The exception got generated by the initialization code that started an instance of a helper class, passing frmImport.ActiveForm as a parameter.

The above got executed before the frmImport contructor, so frmImport.ActiveForm is null.

I fixed it by moving the assignment for the helper class and the ActiveForm parameter to the Form_Load event.

callisto