C# Excel not creating an instance when run outside of debug mode. (IIS instance)

0

Sorry for the poorly worded title. I have an application that will take in an excel file, make some changes, format the data as a dataset and export to excel in C#. when I run either in debug mode (F5) or with ctrl + F5 it has no problem running. The excel sheet is created, filled, and saved to the proper location. when I set up in instance in IIS to test it outside of this method to simulate a user (same machine, browser, etc), it cannot create the excel application. It does not throw an error, it just simply never creates, fills, or moves to location and then says everything worked. I believe the problem (to the best of my knowledge) is with the code here

 Excel.Application excelApp = new Excel.Application();
 excelApp.Visible = true;

To clarify, my excel import at the top is

 using Excel = Microsoft.Office.Interop.Excel;

This problem is hard to understand without an error output. The best information I can provide is what is provided in event viewer.

In the System View I get an error of

 The server {00024500-0000-0000-C000-000000000046} did not register with DCOM within the required timeout.

And in the Application Viewer I get an error of

 Faulting application name: EXCEL.EXE, version: 16.0.9126.2282, time stamp: 0x5b90650a
 Faulting module name: AppVIsvSubsystems32.dll, version: 6.3.9600.18895, time stamp: 0x5a4b127e
 Exception code: 0xc0000142
 Fault offset: 0x0009d4e2
 Faulting process id: 0x13a4
 Faulting application start time: 0x01d45984c26a7014
 Faulting application path: C:\Program Files (x86)\Microsoft Office\Root\Office16\EXCEL.EXE
 Faulting module path: AppVIsvSubsystems32.dll
 Report Id: 001becbd-c578-11e8-80f3-00505689c70f
 Faulting package full name: 
 Faulting package-relative application ID: 

Let me know if anymore information is needed or if anything was unclear

c#
excel
dataset
asked on Stack Overflow Oct 1, 2018 by Nick

2 Answers

0

Try without using interop, and using dynamic variable instead:

Type excelType = Type.GetTypeFromProgID("Excel.Application");
dynamic excelApp = Activator.CreateInstance(excelType);
excelApp.Visible = true;
answered on Stack Overflow Oct 1, 2018 by Aymen Turki • edited Oct 1, 2018 by Aymen Turki
-1

you need to use a different library to zip. EPPlus

answered on Stack Overflow Oct 1, 2018 by go..

User contributions licensed under CC BY-SA 3.0