EDIT: New information
I have narrowed the problem to a specific code. Following code produces the error message (see below in the original part):
public partial class ThisAddIn
{
private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
Globals.ThisAddIn.Application.WorkbookOpen += Application_WorkbookOpen;
}
void Application_WorkbookOpen(Excel.Workbook Wb)
{
int i = 0;
}
private void ThisAddIn_Shutdown(object sender, System.EventArgs e)
{
}
#region VSTO generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InternalStartup()
{
this.Startup += new System.EventHandler(ThisAddIn_Startup);
this.Shutdown += new System.EventHandler(ThisAddIn_Shutdown);
}
#endregion
}
It does not matter whether I unregister the WorkBookOpen event in the ThisAddIn_Shutdown method or not. Whenever this piece of code is present Word gives me the error.
It seems to be a bug in Excel. Can anyone test and confirm my assumption? Does anyone know a workaround?
ORIGINAL
I have a problem with my Excel add-in (VSTO) in a very specific situation. For some reason I can't debug the add-in when it is happening.
In Word it is possible to insert and edit OLE objects. In this specific situation a user wants to insert and edit an Excel sheet (INSERT -> Table -> Excel Spreadsheet).
Let's say that Excel is not running. In an ideal world the Excel process is started by Word when the user edits the spreadsheet. The Excel process is terminated when the Word document is closed. This works fine, if my Excel add-in is deactivated.
If the Excel add-in is activated the user cannot edit the spreadsheet in Word. An error with following message is shown within Word: "The program used to create this object is Excel. That program is either not installed on your computer or it is
not responding. To edit this object, install Excel or ensure that any dialog boxes in Excel are closed". Also the Excel process which was started by Word is not terminated when closing the document or exiting Word. Excel started by the user does not give
any error message. No dialog is opened. The add-in works fine. So there must be an error with the Excel add-in when Excel is started by Word.
I can reproduce the error with and without an attached debugger (Visual Studio). But for some reason there is no exception caught by Visual Studio while the error is happening.
Can anyone help me how to investigate on that error?
Yavuz