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