InfoPath Form Security and Custom Code
Generic error messages are high on my list of pet peeves. Being told that “an error occurred” may be something that you can pass off in a line of business application, especially if the actual error message gets emailed to the help desk or something similar, but it is totally unacceptable in a product targeted towards software developers.
Tonight, when trying to add some managed code to an InfoPath 2007 solution, I ran into one of these horrible errors. InfoPath was presenting me with a highly helpful “InfoPath cannot open the selected form” error message whenever I tried to debugging the solution.
After spending a few minutes scratching my head I remembered that InfoPath forms need to run in Full Trust mode in order to use managed code. I navigated to “Tools>Form Options>Security and Trust” and had a look at the settings, which were still set to the default “Automatically determine security level”. Unfortunately I assumed that, when using this setting, InfoPath would be able to figure out that I was using managed code and select the appropriate security level. Obviously my assumption was incorrect.

After setting the level of trust to “Full Trust” I was finally able to launch the form, complete with managed code.
If I had not previously read about security and trust within InfoPath then I would have had to waste more time floundering on Google with only a generic error message to help me. All that could have been avoided if they had just presented me with a dialog saying “The form has an insufficient trust level to perform this operation”. Well, either that or make the “Automatically determine security level” trust setting actually determine an appropriate trust level in the first place.
Creating a Monster – Part 1 – The Beginning »