ASP.Net Com-InterOp Excel Generation issue when hosting

12

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 host it in the server I'm getting following error, if I'm no user is logged in to the server through Remote desktop Connection.

"Retrieving the COM class factory for component with CLSID {00024500-0000-0000-C000-000000000046} failed due to the following error: 8000401a The server process could not be started because the configured identity is incorrect. Check the username and password. (Exception from HRESULT: 0x8000401A)."

I've set DCOM configurations as well. The strange thing is that at least one user should be connected to the server through RDC. If so everyone can generate excels. If not above error throws. Rest of the functionality of the application works fine.

The server is Windows Server 2008, IIS7. And the users connecting the application through a VPN.

Has any one experienced a issue like this?

Thanks in advance.

c#
asp.net
windows-server-2008
com-interop
asked on Stack Overflow Feb 1, 2012 by Thanushka • edited Feb 1, 2012 by Yahia

9 Answers

12

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.

answered on Stack Overflow Dec 10, 2013 by (unknown user)
4

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.

answered on Stack Overflow Feb 1, 2012 by rofans91
3

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)

answered on Stack Overflow Feb 1, 2012 by Antonio Bakula
3

Just set the Identity to this User and enter the username and password of a user who has sufficient rights. In my case I entered a user of power user group.

answered on Stack Overflow Aug 29, 2012 by ritu • edited Aug 29, 2012 by Jack
2

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.

answered on Stack Overflow Feb 1, 2012 by Yahia • edited Feb 1, 2012 by Yahia
1

I made research on this problem, which I also had. I did that: http://forums.asp.net/t/1093228.aspx

I don't know how good solution it is but it works. :)

Type dcomcnfg in cmd

go to Component Services ->My Computer ->Com Security ->Lauch and Activate Permissions ->Edit Default ->Add...

Now add Network Service and allow all permisions to it.

answered on Stack Overflow Nov 18, 2013 by (unknown user) • edited Dec 10, 2013 by (unknown user)
0

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.

answered on Stack Overflow Jan 29, 2015 by culithay
0

Just create a new user on the machine with admin privilege and assign this user on the Identity Tab of the COM service as per the below image. It works perfectly.

screenshot

answered on Stack Overflow Jun 23, 2020 by Danish • edited Jun 23, 2020 by Matt Ke
-1

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.

answered on Stack Overflow Feb 8, 2012 by Thanushka

User contributions licensed under CC BY-SA 3.0