Microsoft KB Archive/908431

= You may experience compilation errors and run-time errors when you try to set the Visual Studio 2005 Tools for the Office System &quot;Application&quot; object to an &quot;Outlook.Application&quot; object =

Article ID: 908431

Article Last Modified on 1/15/2007

-

APPLIES TO


 * Microsoft Visual Studio Tools for the Microsoft Office System version 2003
 * Microsoft Office Outlook 2003

-





SYMPTOMS
You may experience the following errors when you try to set the Microsoft Visual Studio 2005 Tools for the Microsoft Office System Application object to an Outlook.Application object:
 * Compilation errors
 * Run-time errors



CAUSE
The Microsoft Visual Studio Tools for the Microsoft Office System version 2003 Application object is derived from the Microsoft.Office.Interop.Outlook.Application interface. Therefore, a reference to the Visual Studio Tools for the Office System version 2003 Application object is functionally identical to a reference to the Outlook.Application object.

However, a reference to the Visual Studio 2005 Tools for the Office System Application object is not type identical to a reference to the Outlook.Application object. Instead, the Visual Studio 2005 Tools for the Office System Application object is a wrapper around the Outlook.Application object. Therefore, a reference to the Visual Studio 2005 Tools for the Office System Application object is not functionally identical to a reference to the Outlook.Application object.



WORKAROUND
To work around this issue, change all code references of the Microsoft.Office.Interop.Outlook.Application interface to one of the following references:
 * The Microsoft.Office.Tools.Outlook.Application interface
 * The  .Application interface



MORE INFORMATION
If you have to integrate legacy code, third-party libraries, or code that requires a reference to the Microsoft.Office.Interop.Outlook.Application interface, you can obtain a reference to the native Microsoft.Office.Interop.Outlook.Application interface type in Microsoft Visual Studio 2005. To do this, follow these steps:
 * 1) Obtain a reference to the Visual Studio 2005 Tools for the Office System Application object.
 * 2) Obtain a reference to one of the child collections of the Visual Studio 2005 Tools for the Office System Application object. For example, obtain a reference to the Inspectors collection.
 * 3) Take a reference to the child collection's Application object. For example, take a reference to the Inspectors.Application object.

In Visual Studio 2005, only the native Outlook.Application object is trusted by the Microsoft Outlook object model guard. If you use the Outlook.Application object, you may experience security issues.

