Wednesday, August 18, 2010

Cannot open .xsf file from Visual Studio

When trying to build InfoPath 2007 forms from visual studio 2008, sometimes I got error message "the operation could not be completed" and could not open the form.  This is frustrating, because no further details of that error.


After fighting with this issue many times in the past three years, I guess I found the reason.


There are some bugs in Visual Studio (I believe).


1. When we change the location of the InfoPath project, such as moved to another computer, moved to another folder, checked into TFS server, then been opened by another developer from another computer, etc. This problem might pop up.


2. There are several xml files in the folder "InfoPath Form Template" as below.  The smallest inconsistence in these files would also cause this problem.




3. Visual Studio has its own cache in memory and file system. Sometimes the old version xml file in cache may be checked into TFS.


So, how to fix this issue?

  • Make sure there is enough ram on you development workstation
  • Reboot Visual Studio
If it's your lucky day, this action may fix the problem.
  • Be careful with the file "manifest.xsf". 
Make sure all URL and Folder path appeared in this file are valid in you current environment.   I would recommend to remove the attribute "Publishurl" from the node "xsf:xDocumentClass" if it is there (By Notepad).

  • Keep a separate backup manually once the form is published successfully. TFS is not enough.
If you don't have the backup, don't worry. Take the latest .xsn file (maybe, from SharePoint site), change the file extension to ".cab", then decompress it to a folder. Then you can get most of the files from there.
    • If there are more than one form in a solution (one project per form), only keep one project "active".  Unload other projects.
    • Always check out the whole project before editing anything in it.



    If cannot figure out the reason, or don't want to spend hours on trouble shooting, roll back to the previous backup.  I know it's not a good idea, but maybe it's the best way.


    If anyone get any thoughts, please let me know.

    2 comments:

    1. 2 years after...
      I just found that if you quit visual studio and right click on the manifest.xsf file and choose "design" it will try to open and will show more detail about the error.

      André :)

      ReplyDelete
      Replies
      1. 3 years later...
        That's a very useful piece of information. Thanks André!

        Delete