Infopath 2013 Preview with Code Behind Fails on Sharepoint 2016

Nevine Rizkalla 1 Reputation point
2022-04-07T21:51:08.423+00:00

I have infopath 2013 installed on a server that host SHarepoint 2016. Whenever i create a blank form and attach blank code to it (just the default solution), the preview of the form from inopath client fails giving the following error:
"InfoPath cannot open the selected form because of an error in the form's code.
Object reference not set to an instance of an object."

Once I remove the code, the form preview works normally! I need to be able to preview forms with code behind prior to publishing them to sharepoint. Any clues?

SharePoint Development
SharePoint Development
SharePoint: A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.Development: The process of researching, productizing, and refining new or existing technologies.
2,770 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Yi Lu_MSFT 17,466 Reputation points
    2022-04-08T08:10:29.483+00:00

    Hi @Nevine Rizkalla
    It seems that this error is caused because you are trying to access a property of an object that is null. Have you tried another code? Will it also cause this error?

    Here are two articles for you to refer according to the error message:
    http://www.stuartroberts.net/index.php/2013/02/11/infopath-object-reference-not-setinstance/
    https://www.codeproject.com/Questions/420167/Object-reference-not-set-to-an-instance-of-an-obje

    Note: Microsoft is providing this information as a convenience to you. The sites are not controlled by Microsoft. Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. Please make sure that you completely understand the risk before retrieving any suggestions from the above link.


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.