InfoPath: Unexpected end of file has occurred. The following elements are not closed: dfs:dataFields, dfs:myFields

Just stuck in this error for few hours. Finally solved it. Here is the story…

You have InfoPath form with secondary data source (SharePoint) to retrieve some lookup data. 2 possible reasons causing this error.

1. You have unused secondary data source (SharePoint).

2. You are using the secondary data source (Sharepoint). It does not bind it to any control but using code programming to consume the data.


1. Remove unused secondary data source

2. Add hidden control to bind to the secondary data source. Code remain the same.

This seems only happens where I am using SharePoint as my secondary data source. Web services doesn’t have this problem.