This project has moved. For the latest updates, please go here.

COM Exceptions with NetOffice

May 26, 2014 at 10:59 PM
I'm trying to port an Excel VSTO Addin over to NetOffice. So far I've got the Addin launching, but any time I try to make a call on a NetOffice object I get the following:
----- Source: NetOffice -----
Inner Exception 1: System.MissingMethodException: Method 'System.__ComObject.Add' not found.
   at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams)
   at NetOffice.Invoker.MethodReturn(COMObject comObject, String name, Object[] paramsArray)
System.Runtime.InteropServices.COMException: See inner exception(s) for details.
   at NetOffice.Invoker.MethodReturn(COMObject comObject, String name, Object[] paramsArray)
   at NetOffice.ExcelApi.Workbooks.Add()
   at Hcg.Stinger.Connect.InitializeAutomationAddIn() in D:\Code\Prevision\Source\Hcg\Stinger\Connect.cs:line 541
   at Hcg.Stinger.Connect.OnStartupComplete(Array& custom, MainTaskPane taskPane) in D:\Code\Prevision\Source\Hcg\Stinger\Connect.cs:line 258
The code is pretty straightforward:
Excel.Workbook  book = _excelApp.Workbooks.Add();
I also got the similar error when I called saying the Cursor did not exist, even though it show up in the intellisense:
Excel.Enums.XlMousePointer cursorOriginal = Excel.Enums.XlMousePointer.xlDefault;
_excelApp.Cursor = Excel.Enums.XlMousePointer.xlWait;