Microsoft Interop issue when saving file from excel to csv -The remote procedure call failed. (Exception from HRESULT: 0x800706BE)

Microsoft.Office.Interop.Excel.Application app = new Microsoft.Office.Interop.Excel.Application();                
                Microsoft.Office.Interop.Excel.Workbook wb = app.Workbooks.Open(excelFilePath, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);

Please note ,
I have this issue only when I deploy the application to another server than the dev server. The filess are processed fine on the dev server. Same version of Excel is installed on both servers
Bot the servers are windows 2008.
I have this issue only for certain xls files , some files work fine.
I get these files form different vendors.

I also tried what this article reccomends -
http://stackoverflow.com/questions/28640623/microsoft-excel-cannot-access-the-file-there-are-several-possible-reasons
LVL 1
countrymeisterAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Randy DownsOWNERCommented:
Tried this?

.Workbooks.Open(strPath, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Microsoft.Office.Interop.Excel.XlCorruptLoad.xlExtractData);

Open in new window

countrymeisterAuthor Commented:
That did not help
CtrlAltDlCommented:
Does it work at all on the published server?

Can you open Excel on the server?

What does your Garbage Collecting code look like?  Are you closing and quitting Excel and the spreadsheet when you are done?
CompTIA Network+

Prepare for the CompTIA Network+ exam by learning how to troubleshoot, configure, and manage both wired and wireless networks.

countrymeisterAuthor Commented:
I am closing the workbook, abd the quitting the excel app.

I can open excel on the server
This is what I have in my finally block, wb is the workbook, app is the Excel Aplication

 finally
            {
                if (wb != null)
                    wb.Close(0);
                app.Quit();
                app = null;
               
            }
Randy DownsOWNERCommented:
Do some files consistently fail or is it random?

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
countrymeisterAuthor Commented:
Yes, there are files that constantly file, they are downloaded from vendor website, though the vendor labels these are .xls, the content in these files is something like this



<table cellpadding="0" cellspacing="0" border="1">
<tr><td colspan="6">All Fund Holdings as of 05/20/2015</td></tr>
<tr><td>Number</td><td>Holding</td><td>Ticker</td><td>Shares</td><td>Market Value</td><td>% of net assets</td></tr>
<tr>
<td>1</td><td>Schlumberger Ltd</td><td>SLB US</td><td>2,068,413</td><td>$187,708,479.75</td><td>19.92%</td></tr>
<tr>
<td>2</td><td>Halliburton Co</td><td>HAL US</td><td>2,267,269</td><td>$101,959,086.93</td><td>10.82%</td></tr>
<tr>

The issue is on the Workbooks.open it fails with the rpc call.
I also switched to Workbook.OpenXml and that just hangs wating for a prompt.
So I added extensionhardening to avoid the prompt, but that did not help either.

On the dev server stuff works fine.
Randy DownsOWNERCommented:
That looks like html which would be better opened in a web browser. maybe the files would would if you can get a real .xls file. I am not sure how your DEV server is opening that file in Excel.

Note: I can open html with Excel but it complains about missing files like CSS.
countrymeisterAuthor Commented:
I used HtmlAgility to load the document for the files that were failing and I am good.
Please close this question and refund points
countrymeisterAuthor Commented:
I've requested that this question be closed as follows:

Accepted answer: 0 points for countrymeister's comment #a40791569

for the following reason:

No expert provided any solution
Randy DownsOWNERCommented:
I narrowed the discussion to specific files rather than just saving files in general. In addition I did point out that the file snippet is html rather than xls. Without these I don't see the author finding his own solution of reading with HtmlAgility.
countrymeisterAuthor Commented:
I have no problems in granting you points. but I did know that the snippet I posted is html.
Also this file can be easily parsed on my dev server using excel interop but not the prod server.
Randy DownsOWNERCommented:
Thanks, I thought you probably recognized the snippet. Apparently your production server was touchier about opening html.
countrymeisterAuthor Commented:
thanks
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
.NET Programming

From novice to tech pro — start learning today.