none
unable to find interop RRS feed

  • Question

  • My computer used to have Office 2013, and now runs the office 2016 preview. 

    I'm developing an app to be used with office 2013. 

    I have a reference to excel interop (ver. 15.0.0.0) 

    But when trying to use it I get the exception: 

    Unable to cast COM object of type 'System.__ComObject' to interface type 'Microsoft.Office.Interop.Excel.Application'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{000208D5-0000-0000-C000-000000000046}' failed due to the following error: Interface not registered (Exception from HRESULT: 0x80040155).

    Looking for this value - I've found version 1.8, looking for the typelib of the value I've fonud in the previous key it shows version 1.9.

    What can I do in order to 

    a. make it run in my computer

    b. make the final product run on other computers (not knowing which office version is installed / using either office 2007 or 2013) ?

    Thanks.

    Monday, July 13, 2015 5:11 AM

Answers

  • Hello Daniel,

    I'd recommend referencing the lowest interop assembly which corresponds to the lowest Office version you need to support. Thus, you can be sure that you use only methods and properties available in all Office versions. Starting from .net framework 4.0 you may embed the required interop types in your assembly (see the Embed Interop Types property of the reference). In that case it doesn't matter what interop version is used. Just make sure that you use properties and methods available in all Office versions, or you get an exception at runtime. See Running Solutions in Different Versions of Microsoft Office for more information.

    Also you may find the Interface not registered (0x80040155) on return from COM call page helpful.


    Monday, July 13, 2015 9:19 AM

All replies

  • Hello Daniel,

    I'd recommend referencing the lowest interop assembly which corresponds to the lowest Office version you need to support. Thus, you can be sure that you use only methods and properties available in all Office versions. Starting from .net framework 4.0 you may embed the required interop types in your assembly (see the Embed Interop Types property of the reference). In that case it doesn't matter what interop version is used. Just make sure that you use properties and methods available in all Office versions, or you get an exception at runtime. See Running Solutions in Different Versions of Microsoft Office for more information.

    Also you may find the Interface not registered (0x80040155) on return from COM call page helpful.


    Monday, July 13, 2015 9:19 AM
  • Hi,

    Usually, Excel Object Library(Office 2013) is in the folder,
    C:\Windows\assembly\GAC_MSIL\Microsoft.Office.Interop.Excel\15.0.0.0__71e9bce111e9429c
    \Microsoft.Office.Interop.Excel.dll

    If you could not add it into reference, you might have installed Office 2013 first, and Visual Studio next.
    If so, please try to uninstall Office 2013 and re-install Office 2013.
    Hope this would be helpful.
    Regards,

     
    Monday, July 13, 2015 9:46 AM