Hello all,
I am working on an Excel 2007 VSTO plugin that is throwing COM exceptions on the client but not when debugging on my development machine.
What the plugin does is capture Excel's Startup event, define a specialized style, then add an event handler to the SheetChange event. Anytime a value is changed in the sheet, the cell is set to the new style. All of this is to provide users a way to see the cells they've changed. Code is as follows:
private void ThisWorkbook_Startup(object sender, System.EventArgs e)
{
this.BeforeSave += new Microsoft.Office.Interop.Excel.WorkbookEvents_BeforeSaveEventHandler(ThisWorkbook_BeforeSave);
this.SheetChange += new Microsoft.Office.Interop.Excel.WorkbookEvents_SheetChangeEventHandler(ThisWorkbook_SheetChange);
cfStyle = Globals.ThisWorkbook.Styles.Add("CFStyle", missing);
cfStyle.Font.Color = Excel.XlRgbColor.rgbOrange;
cfStyle.Font.Bold = true;
cfStyle.Interior.Color = Excel.XlRgbColor.rgbLightGray;
cfStyle.Interior.TintAndShade = 0.8;
cfStyle.Borders.LineStyle = Excel.XlLineStyle.xlContinuous;
cfStyle.Borders.Weight = Excel.XlBorderWeight.xlThin;
cfStyle.Borders.Color = Excel.XlRgbColor.rgbDarkSlateGray;
cfStyle.Borders[Microsoft.Office.Interop.Excel.XlBordersIndex.xlDiagonalDown].LineStyle = Excel.XlLineStyle.xlLineStyleNone;
cfStyle.Borders[Microsoft.Office.Interop.Excel.XlBordersIndex.xlDiagonalUp].LineStyle = Excel.XlLineStyle.xlLineStyleNone;
}
When this runs in dev, it runs perfectly. However when it's run on a client machine, I get this exception detail once the VSTO plugin loads. The interesting part is it seems to fail on the first COM interaction, which happens to be setting a Style.Font.Color property.
Here are the exception details:
System.Runtime.InteropServices.COMException (0x800A03EC): Exception from HRESULT: 0x800A03EC
Server stack trace:
Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at Microsoft.Office.Interop.Excel.Font.set_Color(Object )
at TriQuint.DemandPlanning.Workbook.ThisWorkbook.ThisWorkbook_Startup(Object sender, EventArgs e)
at Microsoft.Office.Tools.Excel.Workbook.OnStartup()
at TriQuint.DemandPlanning.Workbook.ThisWorkbook.FinishInitialization()
at Microsoft.VisualStudio.Tools.Office.EntryPointComponentBase.Microsoft.VisualStudio.Tools.Applications.Runtime.IEntryPoint.FinishInitialization()
at Microsoft.VisualStudio.Tools.Applications.AddInAdapter.ExecutePhase(ExecutionPhases executionPhases)
at Microsoft.VisualStudio.Tools.Applications.AddInAdapter.CompleteInitialization()
at Microsoft.VisualStudio.Tools.Office.Internal.OfficeAddInAdapterBase.ExecuteEntryPointsHelper()
Has anyone ever seen anything like this? I've done quite a few validations, such as ensuring the proper versions of .NET, VSTO Interop, Excel 2007, etc etc.
Thanks in advance for any advice! Jim