I'm not quite sure why you're getting that error, but I did try this and it doesn't work, because the new form's view can't be changed until the event handler finishes executing.
One thing you can do is the following:
-
Create a new field in your template called StartingView
-
Add a Form Open rule that will switch the view to a certain view when StartingView has a certain value
-
Create a new form from your template with most of the values as their initial values, except set the StartingView field to the special value you selected for step 2. Save this XML file somewhere InfoPath will be able to access it.
-
Change your code so that it uses the NewFromSolutionWithData, and specify the path to the file saved in step 3 as the first argument. This way, when the new forms are created, they will be loaded with the contents of this XML file as their starting data.
That should do the trick.