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
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)
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:
That worked. And we didn't have to let the computer be locked.
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.
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.
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.
I have the same situation when try to read an uploaded Excel file. Let try these steps. It works for me.
Hope it is helpful for you.