Click here to Skip to main content
16,018,802 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am trying to use the Excel File Dialog window from a asp.net page. it works good from my local computer but gives the following error on the server.

System.Runtime.InteropServices.COMException: Error HRESULT E_FAIL has been returned from a call to a COM component.

[COMException (0x80004005): Error HRESULT E_FAIL has been returned from a call to a COM component.] Microsoft.Office.Interop.Excel.ApplicationClass.get_FileDialog(MsoFileDialogType fileDialogType) +0 FileMoverSetup.FileDirectorySetup.btnProcessedBrowse_Click(Object sender, EventArgs e) in c:\Users\psanders\Documents\Visual Studio 2013\Projects\FileMoverSetup\FileMoverSetup\FileDirectorySetup.aspx.cs:390 System.Web.UI.WebControls.Button.OnClick(EventArgs e) +9628722 System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +103 System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10 System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13 System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +35 System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1724


I have been working on this for days without any luck. any suggestions?? i have tried changing permissions. add impersonate to the web config. nothing seems to work.
Posted

1 solution

Quote:
nothing seems to work

... and it never will.

First, it only ever works on your DEV machine because everything, including the web server, is running as YOU on your desktop.

When deployed on the server, everything runs as a service without any visible desktop. So, the dialog that shows up only shows up on the web server where nobody can see it. The dialog will NEVER show up on the client machine.

Also, Excel Interop (what you're doing) can NOT be used in a web application for various reasons, like re-entrancy and multiple thread problems. It may work so long as one user at a time is using a function in the website but it will fall on its face and crash with the more users using the functions at the same time.
 
Share this answer
 
Comments
philyphil54 22-Sep-15 16:21pm    
thanks for your input. would you have any suggestions as what i could use in the place of Excel Interop. I need a solid folder directory dialog that the user can enter a UNC path too. this is an internal application that they want to use.
Dave Kreskowiak 22-Sep-15 17:11pm    
If the server is going to do the work, there is nothing you can do on the server to show some dialog on the client. You can just put up a textbox on the client and get the path.

What you use on the client really has nothing at all to do with Excel or any operation on the server. All you're doing is getting a string from the user that represents some path somewhere. How you do that is entirely up to you.

On the server, I have no idea what you're doing with Excel, but if you have some processing to do on an Excel workbook I suggest using the "OpenXML SDK". Just Google for it. You're also going to need a ton of tutorials on it. It's got quite a steep learning curve.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900