I've got a .NET Core 3.1 console application that's using Word COM interop, except when it tries to create the Microsoft.Office.Interop.Word.Application
object it throws an exception:
System.Runtime.InteropServices.COMException (0x80070520): Retrieving the COM class factory for component with CLSID {000209FF-0000-0000-C000-000000000046} failed due to the following error: 80070520 A specified logon session does not exist. It may already have been terminated. (0x80070520).
at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean wrapExceptions, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& hasNoDefaultCtor)
at System.RuntimeType.CreateInstanceDefaultCtorSlow(Boolean publicOnly, Boolean wrapExceptions, Boolean fillCache)
at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, Boolean wrapExceptions)
at System.Activator.CreateInstance(Type type, Boolean nonPublic, Boolean wrapExceptions)
at System.Activator.CreateInstance(Type type)
This is the constructor call I'm using:
_app = new Application
{
DisplayAlerts = WdAlertLevel.wdAlertsNone,
Visible = false,
FileValidation = MsoFileValidationMode.msoFileValidationSkip,
Caption = "FOO"
};
What causes this?