I have to create an InfoPath form from c# code. So I use xsd.exe to create c# objects and XmlSerializer to compose xml files.

Also I must define "mso-application" like "progid="InfoPath.Document" versionProgid="InfoPath.Document.3" (for sharepoint 2010) and "mso-infoPathSolution". I have problem with "mso-infoPathSolution" where I must define right "name" and "solutionVersion".

I can get right name of InfoPath form by next code:

FormsService service = SPFarm.Local.GetChild<FormsService>();

but I can't find any solution for "solutionVersion" of Infopath form.

How I can get "solutionVersion" for InfoPath form that was published on SharePoint?

1 Answer 1


I don't believe these make it into the file when using xsd.exe because they are processing instructions, not actually part of the XML data structure. If you need these then update the file as XML and use XPath queries such as:

var ipsNode = xml.SelectSingleNode(
ipsNode.InnerText = "TODO";

I've been down the path of using xsd.exe but try to avoid it now and create my own entity classes. The XML template is stored within the form .xsn which can be extracted like a CAB file. This can be populated with XPath queries (and vice versa to read back). While it's more work up front, once done it is much easier to work with form data:

  • XPath queries can be written to be more flexible and resistant to changes in form structure
  • when problems occur they are easier to debug
  • working with your own code rather than something auto-generated
  • gives you more flexibility, e.g. able to set and extract processing instructions as part of reading the form
  • gives you entities that are not tied to being a particular type such as dataset

Something to consider.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.