In a previous post I talked about how you can use writing values from code in an InfoPath browser form to the Windows Event Log as a workaround for not having Visual Studio to be able to debug a browser-enabled form template in SharePoint.
The only caveat is that you’ll have to give the InfoPath form template Full Trust to be able to write to the Windows Event Log.
If you don’t do this, you may get the following error message:
Request for the permission of type ‘System.Diagnostics.EventLogPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089′ failed.
The code for writing to a Windows Event Log on the SharePoint server where the InfoPath browser form is opened, is pretty straightforward.
After adding a reference to the System.Diagnostics namespace, you can write code similar to the following:
string source = "InfoPath Browser Form";
if (!EventLog.SourceExists(source))
{
EventLog.CreateEventSource(source, "Application");
}
EventLog log = new EventLog("Application");
log.Source = source;
log.WriteEntry("Your message goes here.", EventLogEntryType.Information);
Another workaround similar to writing to the Windows Event Log would be writing to a text file on the SharePoint server for debugging purposes.

Comments to this post were closed 30 days after it was published.