Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

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


View products that this article applies to.

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.

↑ Back to the top


Cause

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

↑ Back to the top


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.

↑ Back to the top


Status

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

↑ Back to the top


More information

Steps to Reproduce the Behavior

  1. Start Microsoft Visual Studio .NET. 2003.
  2. On the File menu, point to New and then click Project.
  3. Under Visual C# Projects, click Windows Application. By default, Form1 is created.
  4. Add a reference to the Microsoft Excel Object Library:
    1. On the Project menu, click Add Reference.
    2. On the COM tab, locate Microsoft Excel 11.0 Object Library, and then click Select.
    3. Click OK in the Add References dialog box to accept your selection.
  5. In Solution Explorer, double-click Form1.cs to display the form in Design view.
  6. On the View menu, click Toolbox to display the Toolbox.
  7. Add a button control to the Form1 form.
  8. Double-click the button on the form to add a Click event handler.
  9. Add the following code to the top of the code window:
    using Excel = Microsoft.Office.Interop.Excel;
  10. 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.

↑ Back to the top


References

For additional information, click the following article number to view the article in the Microsoft Knowledge Base:
311452� INFO: Develop Microsoft Office Solutions with Visual Studio .NET

↑ Back to the top


Keywords: KB824001, kbautomation, kbpending, kbpia, kbbug

↑ Back to the top

Article Info
Article ID : 824001
Revision : 6
Created on : 2/3/2006
Published on : 2/3/2006
Exists online : False
Views : 437