Sometimes working with InfoPath , in my case its InfoPath - 2010, come across a problem of security exception mentioned below :
System.Security.SecurityException was unhandled by user code
Request for the permission of type 'Microsoft.SharePoint.Security.SharePointPermission, Microsoft.SharePoint.Security, Version=220.127.116.11, Culture=neutral, PublicKeyToken=xxxxxx' failed
This exception arises when we are using some code snippet to communicate with SharePoint in any way.
Plus would like to mention that when we use any "Manage Data Connection" , and preview our InfoPath form, it usually prompt a message :
To solve this problem, you have to switch your InfoPath - 2010 form to Full Trust.
To do that, click "File" , then from menu choose "Info" and then "Form Options", and then uncheck "Automatically determine security level", by default its checked, and it will enable 3 radio buttons below this.
You have to choose "full trust", click OK.
Now both the above mentioned warnings and exception should not occur.