InfoPath Object Reference not set Error

After designing an InfoPath form and as you try to upload and register the form to SharePoint, through the Central Administration site for example, you may see the following error:

Object reference not set to an instance of an object

You may also see the following error when previewing the form within InfoPath Designer:

InfoPath cannot open the selected form. There was an error while loading the XML Schema for the form.

Examining the ULS log while uploading the form, some additional information is obtained, none of which really sheds much light on the cause of the problem. We have:

ConstructFromXsnFile failed with unhandled exception System.NullReferenceException: Object reference not set to an instance of an object.

LoadDocumentAndPlayEventLog failed with unhandled exception System.NullReferenceException: Object reference not set to an instance of an object.

and

System.NullReferenceException: Object reference not set to an instance of an object.

All of which pretty much do little more than confirm the original error.

For all three errors above, there is one common exception reported, at least for the error I encountered:

Microsoft.Office.InfoPath.Server.SolutionLifetime.Filters.
FindElementInExpressionByBindingName(BaseControl targetControl, String name)

The form I was designing had some filters defined against data sources bound to a drop down list control. So, first thing to try was to remove the filter, which resulted in the form successfully previewing and deploying to SharePoint.

OK, so why was the filter causing the error? I’ve used filters countless times in the past without seeing this error.

Moving the drop down list (with filter) to another view was also successful. So it can’t be the filter causing the error, even if that is what it originally looked like.

So, back to the view where the error occurs. Looking at it again, I noticed I had some text contained within an unbound field, which was used on most of the views, but not the one I successfully got working with the drop down list in my previous test. So, I tried creating a source for the text box and bound it to the unbound control. In doing this the form correctly previewed and was able to deploy without error.

For a reason I can’t explain fully, having unbound controls declared on your form while setting filters on data sources causes the Object reference not set to an instance of an object error to occur.

The moral or this story is to not have unbound controls in your form. In my case, I removed the text which was displayed in an unbound control (and used in most views) and replaced it with a simple one cell table with content formatted how I wanted it and then copied it over all occurrences of the pesky unbound control.

This entry was posted in InfoPath and tagged . Bookmark the permalink.
0 0 votes
Article Rating
Subscribe
Notify of
guest

Solve the maths problem shown below before posting: *

1 Comment
Inline Feedbacks
View all comments
Jay

Thanks for this post and explaining the steps you took to resolve the issue 🙂