blog community

Welcome to blog community Sign in | Join | Help
in Search

Wouter van Vugt

This blog is no longer maintained and has moved

Strange behavior of the new InfoPath object model

My collegue Bart is delivering an Office 2007 Server Development seminar over here at InfoSupport. During which we found out that working with the new InfoPath object model can be quite.. ehr, bizarre.

The following code does compile when 'web compatibility' is turned off, but turning it on breaks the compiler and intellisense. (the seminar still uses Beta-2, no RTM, I'll go check it out there later..) The code insert an optional section based on the state of a checkbox.

        public void field2_Changed(object sender, XmlEventArgs e)
        {
            if (e.NewValue.Equals("true"))
            {
                this.CurrentView.ExecuteAction(ActionType.XOptionalInsert, "group2_2");
            }
            else
            {
                XPathNavigator node = MainDataSource.CreateNavigator().SelectSingleNode
                                                                 ("/my:myFields/my:group2", NamespaceManager);
                CurrentView.SelectNodes(node, node, "CTRL4");
                CurrentView.ExecuteAction(ActionType.XOptionalRemove, "group2_2");
            }

        }

Now the programmer in me (it is still in me somewhere, even though I am a certified IW), is screaming and shouting. Breaking intellisense is something I can live with, but how the heck do they break the C# compiler?? Does it look at intellisense? I think not! The ActionType enumeration is no longer recognized, and the CurrentView property all of a sudden doesn't contain the ExecuteAction method. Let's all cross our fingers and check out RTM!

[Edit] After a bit more research we found that InfoPath loads an entirely different DLL which contains the Object Model, depending on whether you have the web compat mode turned on or off. Can't say I am too happy with that, especially because the Visual Studio Help will not tell me this when I look at the classes used in the snippet above [/Edit]

 

Published Wednesday, November 08, 2006 1:54 PM by wouterv

Comments

 

Bart Gunneman said:

The students had quite a laugh when I showed them this during the class :)
November 8, 2006 9:13 PM
Anonymous comments are disabled

This Blog

Syndication

News


Add to Technorati Favorites
Powered by Community Server, by Telligent Systems