Missing Close() Method - InfoPath Dev
in

InfoPath Dev

Missing Close() Method

Last post 06-26-2010 07:03 AM by cfernald. 4 replies.
Page 1 of 1 (5 items)
Sort Posts: Previous Next
  • 06-24-2010 09:44 AM

    Missing Close() Method

    Hello,


    I have developed several InfoPath 2007 forms with most of the business logic written in the C# code-behind.  The other day I added a custom 'Exit' button with a code-behind handler.  The handler does a few business-related things and then calls the "Close()' method.  Everything works fine.

    I went to add this same logic to one of my other forms and I got a compile error on the line that had the "Close()" call:  "The name 'Close()' does not exist in the current context".  Huh?

    So I began to compare the working form code with the non-working form code.  The Close() method is defined in a module named "Microsoft.Office.InfoPath.XmlFormHostItem.cs" that resides in the InfoPath cache.  When I compared the XmlFormHostItem.cs module of the first form with the second one, I found the following items were missing from the form that won't compile:

            public virtual bool Dirty { get; set; }
            public virtual object Extension { get; }
            public virtual object Host { get; }
            public virtual bool Hosted { get; }
            public virtual string HostName { get; }
            public virtual Permission Permission { get; }
            public virtual bool Recovered { get; }
            public virtual SignedDataBlockCollection SignedDataBlocks { get; }
            public virtual TaskPaneCollection TaskPanes { get; }
            public virtual string UserRole { get; set; }
            public virtual void Close();
            public virtual object GetWorkflowTasks();
            public virtual object GetWorkflowTemplates();
            public virtual void MergeForm(string fileUrl);
            public virtual void MergeForm(XPathNavigator target);
            public virtual void Print();
            public virtual void Print(bool showPrintDialog);
            public virtual void Save();
            public virtual void SaveAs(string fileUrl);
            public virtual void SetSaveAsDialogFilename(string filename);
            public virtual void SetSaveAsDialogLocation(string pathname);


    Notice that Close() is one of the missing methods.  I figured this might be the result of some difference in the InfoPath settings between the two forms.  I opened Tools/Form Options and compared each category - they were exactly the same.  I looked at the Class View and the Object Browser and could find no difference.  I've cleared cached and re-compiled but the problem still exists.

    Does anyone have any ideas?  I thinking of starting over with a fresh project and pasteing-in my existing code.

    Thanks in advance for any feedback.

    \cbf

    Filed under:
  • 06-24-2010 10:00 AM In reply to

    Sounds like your newer form has browser compatibility turned on.

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 06-24-2010 02:16 PM In reply to

    Everything in Tools-> Form Options matches between the two, including compatability.

  • 06-24-2010 07:48 PM In reply to

    Well, does it have browser compatibility turned on?  this.Close() won't be available if it is.  I can tell you that much.

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 06-26-2010 07:03 AM In reply to

    Yeah, you got that right.  Actually, both forms had Browser Compability enabled. 

    As an experiment, I unchecked Browser Compatability in the form that was compiling.  I compiled and published it but it didn't work - i.e. it would even load.  I sort of expected that.  Then I set Browser Compatability back to enabled and now the form won't compile.  This is a good thing in that both forms are now indicating that the Close() method is unavailable.  And, as you might expect, the 2 XmlFormHostItem.cs modules are identical.

    Now I still need to figure out how to close the forms programatically.

    Thanks for your help.

    \cbf 

     

     

     

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