The default class wrappers that are generated by Microsoft Visual Studio .NET do not allow you to handle events for the Office XP Chart, Spreadsheet, and PivotTable Web components. To handle the events for these components, you can modify the source code for these class wrappers, and then recompile. This article describes how to modify and how to regenerate the class wrappers for the Office XP Web Components so that you can manage their events in a Visual Studio .NET application.
Microsoft Visual Studio .NET generates an event listener class that implements an event interface. This event listener class is passed to the Office Web Components (OWC). The OWC then calls the QueryInterface for the IDispatch interface, instead of the event interface. However, the IDispatch interface for the generated class does not contain the dispatch identifiers (DISPIDs) for the events. To resolve this issue, you can mark the generated class with the ClassInterfaceType.None value to force COM Interop to return IDispatch for the interface instead of for the class. The IDispatch interface does contain the event DISPIDs.
NOTE: The steps in this article assume that you have installed the Microsoft Office XP Primary Interop Assemblies (PIAs). For additional information about the Office XP PIAs, click the article number below to view the article in the Microsoft Knowledge Base:
328912 INFO: Office XP PIAs Available for Download
Start the Visual Studio .NET command prompt.
Create a new directory, and then change to that directory:
md c:\owc10 cd "c:\owc10"
Generate the source code for C# for the Windows forms wrapper: