Word2PDF c# IIS Operation unavailable

1

Application is working fine in visual studio but when I try to run on LocalIIS 10 it stuck on infinite loading. I used this library "https://github.com/cognidox/OfficeToPDF". I already have given all the permission to "exe",destination Folder as well as set DCOM permission.I put the debugger the I found that It stuck after creation of word instance at following line

word = new Microsoft.Office.Interop.Word.Application();

Its also giving exception "System.Runtime.InteropServices.COMException (0x800401E3): Operation unavailable (Exception from HRESULT: 0x800401E3 (MK_E_UNAVAILABLE))" at

word = (Microsoft.Office.Interop.Word.Application)Marshal.GetActiveObject("Word.Application");

try
            {

                word = (Microsoft.Office.Interop.Word.Application)Marshal.GetActiveObject("Word.Application");
            }
            catch (Exception ex)
            {
                Console.WriteLine("Exception: "+ex.ToString());

                int tries = 10;
                try
                {
                    word = new Microsoft.Office.Interop.Word.Application();
                }catch(Exception fs)
                {
                    Console.WriteLine("Exception :"+fs.ToString());
                }
                running = false;
                while (tries > 0)
                {
                    try
                    {
                        // Try to set a property on the object
                        word.ScreenUpdating = false;
                    }
                    catch (COMException)
                    {
                        tries--;
                        Thread.Sleep(500);
                        continue;
                    }
                    // Looks ok, so bail out of the loop
                                       break;
                }
                if (tries == 0)
                {

                    ReleaseCOMObject(word);

                    return (int)ExitCode.ApplicationError;
                }
            }
c#
asp.net
.net
iis
ms-office
asked on Stack Overflow Dec 1, 2018 by Ashish Gehlot

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0