Small Changes: VSTO host item and host controls & InnerObject

In VSTO, we have host item bases (the base classes for the Document, Workbook, Sheet, and Chart project items) and host item controls (member variables of these base classes that are created when you add bookmarks, named ranges, list objects etc. to Word and Excel).

For example, there is a control in VSTO called "Microsoft.Office.Tools.Excel.NamedRange" that has all the properties, methods, and events of Microsoft.Office.Interop.Excel.Range. Prior to RTM, if you looked at the type definition of NamedRange, you would see that the type definition says that it implements the Microsoft.Office.Interop.Excel.Range interface. We discovered that this would cause VSTO 2.0 customizations to not work well with future versions of Office. So to make sure that VSTO 2.0 customizations will work in the future, we removed from the type definition our claim that we implement the Microsoft.Office.Interop.Excel.Range interface--but we left everything else. That is, the NamedRange control still has all the properties, methods, and events of Microsoft.Office.Interop.Excel.Range, it just doesn't claim that it implements the interface in the type definition anymore.

The impact on you is that when you try to pass a NamedRange to one of the 20 or so properties and methods in the Excel object model that take a Microsoft.Office.Interop.Excel.Range (like the Union method for example) you have to use the NamedRange controls "InnerObject" property which returns a Microsoft.Office.Interop.Excel.Range object, effectively returning the inner Microsoft.Office.Interop.Range object that NamedRange aggregates and calls through on when you call a property, method, or event of NamedRange:

Application.Union(myNamedRange1.InnerObject, myNamedRange2.InnerObject ...);

You also can't cast a NamedRange any more to a Microsoft.Office.Interop.Excel.Range, instead use InnerObject again.

Microsoft.Office.Interop.Excel.Range myRange = myNamedRange.InnerObject;

This applies to other controls as well like Microsoft.Office.Tools.Word.Bookmark, Microsoft.Office.Tools.Word.Document, Microsoft.Office.Tools.Word.XMLNode, Microsoft.Office.Tools.Word.XMLNodes, Microsoft.Office.Tools.Excel.Worksheet, Microsoft.Office.Tools.Excel.Workbook, Microsoft.Office.Tools.Excel.ListObject, Microsoft.Office.Tools.Excel.XMLMappedRange, Microsoft.Office.Tools.Excel.ChartObject, etc.