I have an application that uses Word Interop
Microsoft.Office.Interop.Word.Application word = null;
word = new Microsoft.Office.Interop.Word.Application();
//word.ReadFile
//word.SaveAs
It was working fine on one of our servers, however we recently got a new one. New server has Word from the Office Professional Plus 2016 installed (no other applications like Excel or others). On the new server I CAN run this application from my account (this tells me that all components are present on the machine).
However if application is run from the service account, it gets
System.Runtime.InteropServices.COMException (0x80040154): Retrieving the COM class factory for component with CLSID {000209FF-0000-0000-C000-000000000046} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).
at System.Runtime.Remoting.RemotingServices.AllocateUninitializedObject(RuntimeType objectType)
at System.Runtime.Remoting.Activation.ActivationServices.CreateInstance(RuntimeType serverType)
at System.Runtime.Remoting.Activation.ActivationServices.IsCurrentContextOK(RuntimeType serverType, Object[] props, Boolean bNewObj)
at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck)
at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
at System.Activator.CreateInstance(Type type, Boolean nonPublic)
at System.Activator.CreateInstance(Type type)
This looks like an access issue, but I can not pinpoint which particular permission service account is missing. Trying to debug this situation I even gave service account administrator access but it didn't solve the issue.
Any thoughts or suggestions would be greatly appreciated!
P.S. Yes I know MS doesn't recommend it, however I was using Office Automation with success on many projects before, and this particular application was working on another machine. I'm hopeful to find resolution for this issue.