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).
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.
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).
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.
- Right Click on manifest.xsn and click Design
- This should open InfoPath Designer 2010
- Click File, Save As to create a copy of your InfoPath Form
- When prompted to save, save it in the new project folder for your new 2010 project
- You can save it with the same filename if you prefer and you can also leave it in 2007 Compatibility mode
- At this point, check the Design Checker to ensure that the "new" form is compatible with the available target.
- At this point, the form is "updated". It will be ready once it is published.
- Now we need to update the code reference for this project.
- Click on File, Form Options, Programming.
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
- Click OK
- 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.
- Click OK
In InfoPath 2010, Click on the Developer Tab, then Loading Event. This should open up Visual Studio Tools for Applications (2005)
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.
The new Visual Studio Tools for Office project will open and the folder location should be one level down in the Project Folder.
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.
- Attempt to build your project. Resolve any missing namespaces and using statements. Add any necessary dlls to your Project Reference section.
- Set a breakpoint in your code near the top and F5 to ensure that your form executes and loads in the InfoPath 2010 Client.
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.