ASP.Net Com-InterOp Excel Generation issue when hosting

后端 未结 9 1364
野性不改
野性不改 2021-01-04 10:08

In my ASP.Net application I\'m generating a Excel file using MsExcel Object Libby (Com-InterOp) . The application worked fine in the VS dev. environment.

But when I

相关标签:
9条回答
  • 2021-01-04 10:38

    Microsoft does not recommend or support server-side Automation of the Excel application in a server environment like ASP.NET, see here . Better use Excel package plus (xslx) or Excel library (xls)

    0 讨论(0)
  • 2021-01-04 10:42

    In the end I created user who is admin on the computer with the web service, and then I set this user like shown on the screen below:

    enter image description here

    That worked. And we didn't have to let the computer be locked.

    0 讨论(0)
  • 2021-01-04 10:44

    The problem is that the 'Identity' set up for the application lacks sufficient privileges. This could be for several reasons, but before we get into those, let's check out where this identity is configured. Open Control Panel, Administrative Tools, and double-click Component Services. Expand COM+ Applications, right-click the application in question, hit Properties, and switch to the Identity tab.

    One possible reason is that, when setting the identity for your application, you simply chose a user that doesn't have access to the DLL, or to a file or system call the DLL touches.

    If this identity is set to the 'Interactive User', then the above error might occur when the user currently logged in to the machine is a peon, or when nobody is logged in at all. This is the primary reason why this error is never detected in development... the user developing the COM+ application, and in complete control of the machine, is also the user logged in and running as the interactive user.

    You should make sure to use a local user account with sufficient privileges, if that's what your DLL requires. User whom uses VPN may find difficulty due to this.

    0 讨论(0)
  • 2021-01-04 10:47

    Thanks for @Rofans.Net, based on the points provided by him we identified that the server, which the app was hosted was in a 3rd party data center and there is no user logged on to the server all the time. Only logged on users are the RDC users.

    So we managed to have a user all ways logged in and and put the computer in the locked stated so that all ways it has a logged in user.

    This is the only way we found and if anyone found a better way please add.

    Thanks.

    0 讨论(0)
  • 2021-01-04 10:51

    Using Office Interop on the server is NOT supported by MS - see http://support.microsoft.com/default.aspx?scid=kb;EN-US;q257757#kb2

    Since Windows Vista MS introduced several security-related measures which prevent a Windows Service (IIS is just a special case of that) from doing "desktop-like" things... which means you would have to circumvent several security measures (impersonation alone won't cut it!) to get it to work (NOT recommended!).

    NOTE that the Integrated VS web server does NOT simulate the behaviour of IIS regarding permissions etc.

    To deal with Excel in a server-scenario there are several options (free and commercial) out there:

    I can recommend Aspose.Cells and Flexcel... didn't try SpreadsheetGear but hear+read lots of good things about it.

    Free options (though for xlsx format only!) are for example OpenXML 2 from MS and EPPlus.

    0 讨论(0)
  • 2021-01-04 10:52

    I have the same situation when try to read an uploaded Excel file. Let try these steps. It works for me.

    1. Create a local account (set password and tick never expired)
    2. Add created account in step 1 to group IIS_IUSRS
    3. Modify your web config ...
    4. Logoff your server and try.

    Hope it is helpful for you.

    0 讨论(0)
提交回复
热议问题