none
Transition into COM context 0x57edd8 for this RuntimeCallableWrapper failed with the following error: System call failed. (Exception from HRESULT: 0x80010100 (RPC_E_SYS_CALL_FAILED)). RRS feed

  • Question

  • Hello,

    I am trying to read docx file using Interop and file size is approximately 20MB. When I am reading file as iterating through paragraphs, I am getting exception as :

    "Transition into COM context 0x57edd8 for this RuntimeCallableWrapper failed with the following error: System call failed. (Exception from HRESULT: 0x80010100 (RPC_E_SYS_CALL_FAILED)). This is typically because the COM context 0x57edd8 where this RuntimeCallableWrapper was created has been disconnected or it is busy doing something else. Releasing the interfaces from the current COM context (COM context 0x57ec68). This may cause corruption or data loss. To avoid this problem, please ensure that all COM contexts/apartments/threads stay alive and are available for context transition, until the application is completely done with the RuntimeCallableWrappers that represents COM components that live inside them."

    I am using simple winform application and it is not multi-threaded. 

    Please help me as I am not able to resolve this error.

    • Moved by DotNet Wang Tuesday, February 2, 2016 8:44 AM
    Friday, January 29, 2016 12:31 PM

All replies

  • Hi PriyankaL3,

    Visual Studio Integrate forum is aim to discuss and ask questions about extending and integrating with Visual Studio.

    >>When I am reading file as iterating through paragraphs, I am getting exception

    Could you share your code? I will help you move your thread to right forum for dedicated help based on your code.

    Best Regards,
    Li Wang


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, February 1, 2016 5:42 AM
  • Hi Li Wang,

    Please find code snippet as below:

    string cellContent = String.Empty;
                string requirementNo = String.Empty;
                string requirementDescription = String.Empty;
                Microsoft.Office.Interop.Word.Application word = null;
                Microsoft.Office.Interop.Word.Document doc = null;
                object miss = System.Reflection.Missing.Value;
                List<Record_Requirement> lstReqRecords = new List<Record_Requirement>();
                List<Record_Requirement> lstDistinctReq = new List<Record_Requirement>();
                try
                {
                    string strReplaceChars = "[\r\a\f\n\v ]";
                    string strStartPatternOfReq = String.Empty;
                    string strRequirementPattern = GetGenericPattern(strPatternToMatch, strReplaceChars, bMatchComplete, out strStartPatternOfReq);

                    if (String.IsNullOrEmpty(strRequirementPattern))
                    {
                        return null;
                    }
                    
                    //Open word document using interop                
                    object objReadOnly = true;
                    object path = strFilePath;
                    word = new Microsoft.Office.Interop.Word.Application();
                    doc = word.Documents.Open(ref path, ref miss, ref objReadOnly, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss);
                    progressBarControllerEvent.Invoke(this, new MessageEvents(doc.Tables.Count));
                                
                    string strPrevParaText = String.Empty;
                    string strCurrentParaText = String.Empty;
                    Regex regex = new Regex(strRequirementPattern);    
                    //Get details of first paragraph
                    strPrevParaText = strCurrentParaText = doc.Paragraphs[1].Range.Text.ToString();
                    progressBarControllerEvent.Invoke(this, new MessageEvents(doc.Paragraphs.Count));
                    for (int para = 1; para <= doc.Paragraphs.Count; para++)
                    {
                        strCurrentParaText = doc.Paragraphs[para].Range.Text.ToString();
                            
                        string strParaText = strPrevParaText + strCurrentParaText;
                        strParaText = Regex.Replace(strParaText, "[\r\a\f\n\v\t ]", String.Empty);
                        if (String.IsNullOrEmpty(strParaText))
                        {
                            continue;
                        }                                            
                        foreach (Match matchParaContent in regex.Matches(strParaText))
                        {                           
                            Record_Requirement req = new Record_Requirement();
                            req.SRDRequirementNo = matchParaContent.Value;
                            lstReqRecords.Add(req);                            
                        }
                        
                        strPrevParaText = strCurrentParaText;
                        progressBarControllerEvent.Invoke(this, new MessageEvents(para));
                    }               

    Monday, February 1, 2016 10:48 AM
  • Hi PriyankaL3,

    Based on your code. We moved your thread to Word for Developer forum for better support.

    Best Regards,
    Li Wang


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, February 2, 2016 8:45 AM
  • Can anybody help me regarding above question? Urgent!
    Tuesday, February 9, 2016 10:43 AM