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.
When creating a Visual WebPart, sometimes you want the main functionality to be contained within the user control and not the WebPart, so that, for example, you can use the WebPart on multiple pages, one where the WebPart is hosted and users can edit the properties and another where only the user control is loaded and no WebPart manager, or WebPart zones, are available to allow editing of the properties.
In the later case, the properties defined in the WebPart would either be set to default values or be retrieved from the query string.
Now, how to setup the user control to receive the WebPart’s property values when contained in a WebPart?