|Important||This document may not represent best practices for current development, links to downloads and other resources may no longer be valid. Current recommended version can be found here. ArchiveDisclaimer|
How to: Preview and Debug Form Templates that Require Full Trust
Last modified: June 02, 2009
Applies to: InfoPath 2010 | InfoPath Forms Services | Office 2010 | SharePoint Server 2010 | Visual Studio | Visual Studio Tools for Microsoft Office
By default, if you attempt to debug or preview a managed-code project that contains code that invokes an object model member that requires full trust, such as the LoginName property which requires access to information about the user's login domain, Microsoft InfoPath 2010 will display the following error messages.
"An unhandled exception has occurred in the form's code." Followed by, "InfoPath cannot complete this action, because of an error in the form's code."
Focus will move to the line of code in the code editor that is calling the member that requires full trust, and the following message will be displayed: "SecurityException was unhandled by user code - Request failed".
To allow the form template's business logic to call this member when it is being debugged or previewed, you must set your form template's security level to Full Trust as described in the following procedure.
Set your form's security level to Full Trust
In InfoPath, open the form template in design mode.
Click the File tab, and then click Form Options on the Info tab.
In the Category list, click Security and Trust.
Under Security Level, clear Automatically determine security level.
Select Full Trust, and then click OK.
After this procedure is performed, you can debug your project as described in How to: Preview and Debug InfoPath Form Templates with Code.
Successfully deploying a managed code form template that requires full trust requires additional steps, such as digitally signing, or installing and registering the form template. For information on deploying a managed code form template after it is debugged see, How to: Deploy InfoPath Form Templates with Code.