Microsoft.Office.Interop.Word.dll - InvalidCastException

0

I have Office 365 installed on my machine. Particularly MS Word version is 2012.

I have created C# project (VS 2019) and referenced microsoft word 16.0 object. It appeared as C:\WINDOWS\assembly\GAC_MSIL\Microsoft.Office.Interop.Word\15.0.0.0__71e9bce111e9429c\Microsoft.Office.Interop.Word.dll.

at that following code

Application application = new Application();
var document = application.Documents.Open(args[0]) 

throws

System.InvalidCastException: 'Unable to cast COM object of type 'Microsoft.Office.Interop.Word.DocumentClass' to interface type 'Microsoft.Office.Interop.Word._Document'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{0002096B-0000-0000-C000-000000000046}' failed due to the following error: Interface not registered (Exception from HRESULT: 0x80040155).' exception.

I have checked \HKEY_CLASSES_ROOT\Wow6432Node\Interface{0002096B-0000-0000-C000-000000000046}\TypeLib registry entry and it is empty (my machine is 64 bit).

I tried to run my executable on other machines but got the same error. Please advise.

c#
office-interop
asked on Stack Overflow Dec 16, 2020 by user3599725

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0