I am getting the "form has closed" error whenever I add any SharePoint code at all to my LoadingEventHandler for my InfoPath form. I have been able to do non-SP stuff such as modify the value of a field, but as soon as I add in code like:
SPSite site = SPContext.Current.Site;
or
using(SPSite siteCollection = new SPSite("...url"))
{
}
Once code like that is added, I get that "form has closed" error upon opening the form. Am I missing something, a dll reference or something? Should this work?