Skip Ribbon Commands
Skip to main content

Blog

:

Quick Launch

Blog > Posts > Update InfoPath 2007 Visual Studio Project to InfoPath 2010
February 14
Update InfoPath 2007 Visual Studio Project to InfoPath 2010

Problem:

You have created a business critical form(s) in SharePoint 2007. This form was generated using the Visual Studio 2008 InfoPath Form Template (not through VSTA in 2007). Now that you've moved/migrated to SharePoint 2010 and need to do some maintenance on this form, you realize that you cannot upgrade the form to Visual Studio 2010 because it is no longer supported (should be, but it's not).

Solution:

Having around 6 critical forms in our project, I was determined to find a path. I did not want to rewrite these forms for 2010.

Here are the steps to upgrade your InfoPath 2007 Visual Studio Template forms to work with InfoPath 2010 with Visual Studio Tools for Applications.

  1. Copy your 2007 Visual Studio InfoPath 2007 Project folder to the machine that has InfoPath 2010.


    NOTE:
    You cannot run InfoPath 2007 and 2010 on the same machine. I recommend having a separate environment to develop your 2010 solutions (if you already are not doing this).

  2. In the InfoPath 2007 Visual Studio Project, the InfoPath internal files are by default extracted (or not compressed) to the InfoPath Form Template folder within your project. Open up the InfoPath Form Template folder and look for the manifest.xsn file. 
     

    manifestfile.png

  3. Right Click on manifest.xsn and click Design
  4. This should open InfoPath Designer 2010
  5. Click File, Save As to create a copy of your InfoPath Form
  6. When prompted to save, save it in the new project folder for your new 2010 project
  7. You can save it with the same filename if you prefer and you can also leave it in 2007 Compatibility mode
  8. At this point, check the Design Checker to ensure that the "new" form is compatible with the available target.
  9. At this point, the form is "updated". It will be ready once it is published.
  10. Now we need to update the code reference for this project.
  11. Click on File, Form Options, Programming.
  12. Check to ensure that a .vbproj OR a .csproj file is not associated in the Project Location for Visual Basic or C# code section. If there is just a folder path, then click on Remove Code. NOTE: If there is a project here, it will delete the code

       

    ProgrammingLanguage.png   

  13. Click OK
  14. Reopen Programming (same steps as in 11) and ensure that you are prompted to Change Language. Select your language and Copy the location of the 2010 folder where your 2010 InfoPath form resides. Paste it into the Project location for Visual Basic and C# code text box.
  15. Click OK
  16. In InfoPath 2010, Click on the Developer Tab, then Loading Event. This should open up Visual Studio Tools for Applications (2005)

       

     DeveloperCodeEditor.pngStartVSTA.png

    NOTE: If you prefer to use any other VSTA event type, that would also work. The goal here is to create a new Visual Studio Tools for Applications project that is associated with the new 2010 InfoPath Form.

  17. The new Visual Studio Tools for Office project will open and the folder location should be one level down in the Project Folder.

       

     FolderLocation.png

  18. Open your old FormCode.cs in your favorite Text Editor and move the code into your new Visual Studio Tools for Applications FormCode.cs. I would verify the namespace of each of the modules.

    NOTE: I would leverage the new VSTA namespace and move all of the code from public partial class FormCode down.

  19. Attempt to build your project. Resolve any missing namespaces and using statements. Add any necessary dlls to your Project Reference section.
  20. Set a breakpoint in your code near the top and F5 to ensure that your form executes and loads in the InfoPath 2010 Client.
  21. Once your code is verified, publish your form using File, Publish and select the appropriate publishing options.

    NOTE: When updating/upgrading, we had to change the Trust level of the form to Domain from Full Trust. If your form is not loading as expected, verify that you have the appropriate Security Settings. These can be adjusted by clicking File, Form Options, Security and Trust.

If you have any questions or comments, please feel free to let me know.

Comments

There are no comments for this post.

Add Comment

Items on this list require content approval. Your submission will not appear in public views until approved by someone with proper rights. More information on content approval.

Title


Body *


3=8=? *


to keep the bots out

Attachments