Tuesday 7 July 2009

How to create Class from InfoPath Schema

  1. On the File menu, click Save As Source Files and save the form files in a folder on your local computer. There will be a file called myschema.xsd among the files you just saved.
  2. Close InfoPath.
  3. Open a Visual Studio 2005 Command Prompt which you can access via Start > Programs > Microsoft Visual Studio 2005 > Visual Studio Tools.
  4. At the command-line prompt, use the cd command to navigate to the folder where you saved the form files. To generate a C# class for the form, at the command-line prompt type:
    1. xsd myschema.xsd /c /l:cs
  5. This will create a C# file named myschema.cs for the InfoPath form.

Note: Once you have created the class and examine it, you will notice that the name of the class is the same as the name of the root node of the InfoPath form. So if you want the generated class to have a meaningful name other than myFields, which is the default name assigned to the root node of an InfoPath form, you must change the name of the root node in InfoPath to the name you want the generated class to have, before you create the .NET class.

No comments:

Post a Comment