Click here to Skip to main content
15,886,422 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Hi All,
I am uploading .xls file to sql server 2008 database, First Uploading .xlsx file to database is successful but after first uploading it gives exception of COMException was unhandled by user code. with message "The RPC server is unavailable. (Exception from HRESULT: 0x800706BA)"


i am using cod eto kill process like :
File.Delete("FilePath");
C#
Process[] prs = Process.GetProcesses();
       List<int> excelPID = new List<int>();
       foreach (Process p in prs)
           if (p.ProcessName == "EXCEL")
               excelPID.Add(p.Id);

       prs = Process.GetProcesses();

       foreach (Process p in prs)
       {
           if (p.ProcessName == "EXCEL" && excelPID.Contains(p.Id))
           {
               p.Kill();
           }
       }


//as well as I used below code also..
C#
foreach (Process p in Process.GetProcesses())
       {
           if (p.ProcessName == "EXCEL")
               p.Kill();
       }



m not getting what is exact issue.Provide solution.

Thanks.
Posted
Comments
Herman<T>.Instance 9-Aug-11 8:14am    
when you debug, which line is giving the error?
[no name] 11-Aug-11 4:44am    
Vinod Salunke - 13 secs ago
Thanks for reply, I am getting error on line
Workbook wbfirst = xlApp.Workbooks.Open(@path + "\\" + excelupload.FileName, 0, true, 5, "", "", true, Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, "\t", false, false, 0, true, 1, 0);

The same Exception RPC server is unavailable.
Vivek Krishnamurthy 9-Aug-11 8:22am    
This could be due to some of the automation objects are not released properly. Are you using excel automation ?
Also, if you are using check if you have Primary Interop assemblies are installed on the target machine.

1 solution

 
Share this answer
 

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