0

Everything works fine localy, but when deployed on the server, I always get the following error :

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)).

So I checked this : Retrieving the COM class factory for component with CLSID {XXXX} failed due to the following error: 80040154

But so far it did not solve the issue, what I tried :

  • Putting target platform to 86x in project setting
  • Check the "autorize unsafe code" box in project setting
  • Enable 32bit app in advanced setting of iis app pool

I'm through with this, here's an exemple of how it's coded :

Word.Application wordApp = new Word.Application();
myWordDoc = wordApp.Documents.Open(ref NomFichier, ref missing, ref readOnly,
                                    ref missing, ref missing, ref missing,
                                    ref missing, ref missing, ref missing,
                                    ref missing, ref missing, ref missing,
                                    ref missing, ref missing, ref missing, ref missing);
myWordDoc.Activate();

// Other operations

myWordDoc.SaveAs2(ref EnregistrerComme, ref missing, ref missing, ref missing,
                        ref missing, ref missing, ref missing,
                        ref missing, ref missing, ref missing,
                        ref missing, ref missing, ref missing,
                        ref missing, ref missing, ref missing);

myWordDoc.Close();
wordApp.Quit();

My guess is : There has to be something wrong with iis since it work localy (but I wouldn't bet on it)...

Antoine Pelletier
  • 3,164
  • 3
  • 40
  • 62
  • 1
    Is Office installed on the server? – Ivan-San Aug 26 '22 at 14:10
  • @Ivan-San Just did it... Same error – Antoine Pelletier Aug 26 '22 at 14:52
  • 1
    The following may be helpful: [Considerations for server-side Automation of Office](https://support.microsoft.com/en-us/topic/considerations-for-server-side-automation-of-office-48bcfe93-8a89-47f1-0bce-017433ad79e2) – Tu deschizi eu inchid Aug 26 '22 at 16:09
  • Ha ! So basically, it's hopeless. I should have known. – Antoine Pelletier Aug 26 '22 at 17:24
  • Some have succeeded in getting it to work. However, it's not recommended. Interop is somewhat slow as well. You may see if NuGet package [DocumentFormat.OpenXml](https://github.com/OfficeDev/Open-XML-SDK) meets your needs. Under "Related Tools", you may find the [Open XML SDK 2.5 Productivity Tool](https://github.com/OfficeDev/Open-XML-SDK/releases/tag/v2.5) helpful. See also [DocumentFormat.OpenXml Namespace](https://learn.microsoft.com/en-us/dotnet/api/documentformat.openxml?view=openxml-2.8.1). – Tu deschizi eu inchid Aug 27 '22 at 16:29
  • We decided to use PDF instead of word – Antoine Pelletier Sep 09 '22 at 19:01

0 Answers0