Migrating InfoPath 2007 forms with code behind to InfoPath 2013 on SharePoint 2016 - InfoPath Dev

InfoPath Dev

Use our Google Custom Search for best site search results.

Migrating InfoPath 2007 forms with code behind to InfoPath 2013 on SharePoint 2016

Last post 11-18-2022 10:38 AM by mole-person. 3 replies.
Page 1 of 1 (4 items)
Sort Posts: Previous Next
  • 10-24-2022 08:24 AM

    Migrating InfoPath 2007 forms with code behind to InfoPath 2013 on SharePoint 2016

    Hi, I have been tasked with migrating InfoPath 2007 browser-enabled Admin-Approval forms with lots of code behind to InfoPath 2013 which was hosted on SharePoint 2007 and must be migrated to SharePoint 2016.  I have tried manually editing manifest.xsf to update the versions and servers to no avail.  I have also tried to open the template .xsn file in InfoPath 2013 which works, I can see the form, but clicking on Developer > Code Editor leads to a "The Visual Basic or C# project for this form template cannot be found" warning, which I can browse to and select the .csproj file.  This then pops a an error that is only readable in Event Viewer "The parameter is incorrect". 

    I have also tried opening the .csproj file in VS2012 Pro but VS says "Unsupported - This version of Visual Studio does not have the project types installed or does not support them..."  And "One-way upgrade - Visual Studio will automatically make functional changes to the following projects in order to open them..." then shows the Solution file .sln .  If I click "OK" then the solution is upgraded but in VS the project is marked "incompatible" and expanding the project. has a message "This project is incompatible with the current edition of Visual Studio."

    When I look at the .csproj I can see that the .Net version would need to be updated (but to what?) and the server paths and file paths would need to be updated.  Looking at an InfoPath 2013 .csproj file, there are a lot of differences.  When I tried to relatively closely match the files I was still running into issues and errors.

    Any tips or resources for updating or migrating this code behind form?  Should I try to create a new InfoPath 2013 form and somehow add the code?   How do would I create a new VS project for a form?  I am using Visual Studio 2012 and VSTA 2012 (though I do have access to other versions of VS, including 2019 and 2022) InfoPath 2013 required that VS 2012 and VSTA be installed to use the Code Editor.


    Thank you!

  • 10-28-2022 10:11 AM In reply to

    Re: Migrating InfoPath 2007 forms with code behind to InfoPath 2013 on SharePoint 2016

    An update for anyone else in this unfortunate predicament.  It is possible to publish an InfoPath 2007 Web browser Admin Approve form to SharePoint 2016.

    1. Need InfoPath 2013, Visual Studio 2012 (I used Professional), and Visual Studio Tools for Applications 2012.  May need to Check for Updates and reboot.
    2. In InfoPath 2013 Designer, open your template (.xsn file) and go to File > Advanced Form Options > Programming and make sure the "Form template code language" is set (in my  case to C#) and the "Target version" is set to "InfoPath 2007". 
    3. Click the "Remove code" button. 
    4. Then click the browse button to browse for a location to create a new .csproj file.
    5. Click OK
    6. You can then add your code as required to FormCode.cs and other files. 

    In this form's case, there were about 10MB of code behind, several class files, and several Web References.  I had to update hundreds of lines of code and xml to point to the new server and libraries. Also had to update the project properties to use .NET framework 4.8 and get the .DLLs from the server (Microsoft.SharePoint.dll and a few others) for my dev vm. AAll told, it took a few hours to get a deployable form.  In any case, it worked, well, mostly. 

    I am having an issue that seems to be caused by the March 2021 CU and "DeserializeVersion1 failed with unhandled exception Microsoft.Office.Server.Security.SafeSerialization+BlockedTypeException: SafeSerialization[Context=EnhancedBinaryReader Deserialization]".  I do not have a pre-March 2021 Microsoft.InfoPath.dll.  I did temporarily disable the "Web Page Security Validation" for the dev environment Web Application (Central Admin > Application Management > Manage Web Applications > select your Web Application >  General Settings > "Web Page Security Validation" to Off. Then do an IISRESET in PowerShell>Administrator).  The code-behind does have 50-60 lines of code that uses "FormState Dictionaries" and may be part of the issue as some Reddit users claimed that rewriting the code to not use FormState dictionaries worked for them.  Off to my next rabbit hole!

    Filed under:
  • 10-28-2022 10:18 AM In reply to

    Re: Migrating InfoPath 2007 forms with code behind to InfoPath 2013 on SharePoint 2016

    Thanks for all the details here! We had a problem with Form State dictionaries and had to revise qRules so as not use them, I feel your pain.
    Hilary Stoupa

  • 11-18-2022 10:38 AM In reply to

    Re: Migrating InfoPath 2007 forms with code behind to InfoPath 2013 on SharePoint 2016

    An update regarding the "DeserialiazationVersion1 failed with unhandled exception...SafeSerialization...EnhancedBinaryReader Deserialization" issue, paraphrasing a Microsoft Premiere Support Engineer: there are three options:

    1) remove/rewrite the code that uses FormState especially if the type is String or List. [Not possible in my case]

    2) downgrade server patches/CUs to DEC 2020!  Lock the server down.

    3) Install fresh SharePoint server, and upgrade to DEC 2020 patch.  Lock the server down.

    We elected option 3 (thanks L!) and the issue was resolved.

    Key take away is this is not a Developer issue this is a Server-side validation issue that was introduced in the MAR 2021 security patch due to at least one disclosed/discovered vulnerability.  Beyond frustrating Developer Experience.  There should be more information about this issue but I guess not many companies are running InfoPath with code behind as much any more.  This issue cost the company $xxx,xxx dollars in Engineering, Developer, Security Team, Infra team, C-level, etc. time and effort to "resolve".  The Microsoft Engineer did state that Microsoft is aware of the issue and that developers are working on remediating the issue but that an ETA is unknown at this time.

Page 1 of 1 (4 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.