When I had Code-behind for business logic in Infopath forms like:
XPathNavigator nav = MainDataSource.CreateNavigator();
nav.SelectSingleNode("//my:CurrentUser", NamespaceManager).SetValue("SOME Values");the following Warning message was shown:
Warning Message:
Object reference not set to an instance of an object.
System.NullReferenceException: Object reference not set to an instance of an object.
at ItemCreation.FormCode.FormEvents_Loading(Object sender, LoadingEventArgs e)
at Microsoft.Office.InfoPath.Server.SolutionLifetime.FormEventsHost.<>c__DisplayClass6.<>c__DisplayClassa.
at Microsoft.Office.InfoPath.Server.Util.DocumentReliability.InvokeBusinessLogic(Thunk thunk)
at Microsoft.Office.InfoPath.Server.SolutionLifetime.FormEventsHost.<>c__DisplayClass6.
at Microsoft.Office.InfoPath.Server.SolutionLifetime.FormEventsHost.<>c__DisplayClass34.
at Microsoft.Office.InfoPath.Server.DocumentLifetime.OMExceptionManager.CallFormCodeWithExceptionHandling(UserMessages userMessages, OMCall d)
An entry has been added to the Windows event log of the server.
Log ID:5337
Seems the Error use to come when ever we try to SET VALUE.
instead of directly setting the value. you can us like
Solution:
You can have a public method
Resource: http://www.dennispoint.com/Lists/Posts/Post.aspx?ID=27
Seems the Error use to come when ever we try to SET VALUE.
instead of directly setting the value. you can us like
Solution:
You can have a public method
public void writeToNode(XPathNavigator xpathNav, string xpath, string value)
{
xpathNav.SelectSingleNode(xpath, this.NamespaceManager).SetValue(value);
}
And use the following code to set value:
writeToNode(nav,"//my:CurrentUser","Some Values");
Hope IT Helpz
Fauzi
1 comment:
You sir are a legend!
Saved me so much headache.
I have no idea why infopath does that randomly. Whats really weird is it was fine on our dev box, but on production this suddenly started happening.
Thank you so much.
Jazak Allah Khair
Post a Comment