Click here to Skip to main content
15,891,951 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
The object invoked has disconnected from its clients. (Exception from HRESULT: 0x80010108 (RPC_E_DISCONNECTED))

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.Runtime.InteropServices.COMException: The object invoked has disconnected from its clients. (Exception from HRESULT: 0x80010108 (RPC_E_DISCONNECTED))

my code;
C#
private void GetExcel(string fileName)
       {

           // string filenamecmp = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"App_Data\CMPDATAFILES\" + FileUpload1.FileName);

           string str = string.Empty;
           Application application = null;
           Workbook workbook = null;
           Worksheet xlWs = null;
           Dictionary<string,> dictionarySingleValue = new Dictionary<string,>();
           try
           {
               application = (Application)Activator.CreateInstance(Type.GetTypeFromCLSID(new Guid("00024500-0000-0000-C000-000000000046")));
               if (application == null)
               {
                   Console.WriteLine("EXCEL could not be started. Check that your office installation and project references are correct.");
               }
               else
               {
                   application.Visible = false;
                   workbook = application.Workbooks.Open(fileName, 0, false, 5, "", "", true, XlPlatform.xlWindows, "\t", false, false, 0, true, 1, 0);
                  // workbook = application.Workbooks.Open(fileName, 0, false, 5, "", "", true, XlPlatform.xlWindows, "\t", false, false, 0, true, 1, 0);

                   string str2 = System.IO.Path.GetFileName(this.fileuploader.FileName);
                   string fileNameWithoutExtension = System.IO.Path.GetFileNameWithoutExtension(this.fileuploader.FileName);
                   for (int i = 1; i <= workbook.Worksheets.Count; i++)
                   {
                       if (!((Worksheet)workbook.Worksheets[i]).Name.StartsWith("Sheet"))
                       {
                           string str5;
Posted
Updated 25-Oct-15 21:35pm
v3
Comments
Andreas Gieriet 25-Oct-15 13:04pm    
Already tried to run in the debugger? Where does the exception occur?
Regards
Andi
marwakhaled1990 19-Jul-18 7:42am    
in other computer this exception show
PIEBALDconsult 25-Oct-15 13:18pm    
Avoid Interop. Try using ADO.net with the OleDb provider and the ACE engine.

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