Microsoft KB Archive/824001

= BUG: The Visual C# .NET IDE Stops Responding When You Add Either an Excel SheetSelectionChange Event or an Excel SheetBeforeRightClick Event =

Article ID: 824001

Article Last Modified on 2/3/2006

-

APPLIES TO


 * Microsoft Visual C# .NET 2003 Standard Edition
 * Microsoft Office Excel 2003
 * Microsoft Visual Studio Tools for the Microsoft Office System version 2003

-





SYMPTOMS
You create a Visual C# .NET application that uses the Microsoft Excel 11.0 Object Library. While you type code to handle certain Excel events, the IDE stops responding.



CAUSE
This problem is caused by the SheetSelectionChange event and the SheetBeforeRightClick event.



WORKAROUND
Start a text editor such as Notepad, type the line of code that causes the problem, and then paste the code into the Visual Studio code editor.



STATUS
Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.



Steps to Reproduce the Behavior
 Start Microsoft Visual Studio .NET. 2003. On the File menu, point to New and then click Project. Under Visual C# Projects, click Windows Application. By default, Form1 is created. Add a reference to the Microsoft Excel Object Library:  On the Project menu, click Add Reference.</li> On the COM tab, locate Microsoft Excel 11.0 Object Library, and then click Select.</li> Click OK in the Add References dialog box to accept your selection.</li></ol> </li> In Solution Explorer, double-click Form1.cs to display the form in Design view.</li> On the View menu, click Toolbox to display the Toolbox.</li> Add a button control to the Form1 form.</li> Double-click the button on the form to add a Click event handler.</li>  Add the following code to the top of the code window: using Excel = Microsoft.Office.Interop.Excel; </li>  Type (do not paste) the following code in the Click event handler for the button.

Note You must actually type this code to reproduce the problem. Excel.Application oApp = new Excel.Application; Excel.Workbook oBook = oApp.Workbooks.Add(System.Type.Missing); oBook.SheetSelectionChange += new Excel.WorkbookEvents_SheetSelectionChangeEventHandler(SheetSelectionChange); After you close the parentheses on the last line, notice that the Visual Studio IDE stops responding. </li></ol>

<div class="references_section">