Share via

Reason of issue

Peter_1985 2,691 Reputation points
May 26, 2021, 9:05 AM

Hi,
Can you have to Stacktrace got below?

Unhandled Exception: System.Runtime.InteropServices.COMException: Creating an instance of the COM component with CLSID {0006F03A-0000-0000-C000-000000000046} from the IClassFactory failed due to the following error: 8001010a The message filter indicated that the application is busy. (Exception from HRESULT: 0x8001010A
(RPC_E_SERVERCALL_RETRYLATER)).
at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck)
at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, StackCrawlMark& stackMark)
at System.Activator.CreateInstance(Type type, Boolean nonPublic)
at System.Activator.CreateInstance(Type type)
at Validate_File1.Program.Main(String[] args)

Visual Studio
Visual Studio
A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.
5,368 questions
C#
C#
An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.
11,217 questions
Visual Studio Debugging
Visual Studio Debugging
Visual Studio: A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.Debugging: The act or process of detecting, locating, and correcting logical or syntactical errors in a program or malfunctions in hardware. In hardware contexts, the term troubleshoot is the term more frequently used, especially if the problem is major.
1,017 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Peter_1985 2,691 Reputation points
    May 27, 2021, 2:05 AM

    It is in VS 2015. See codes below

    using System;
    using System.IO;
    using System.IO.Compression;
    using System.Linq;
    using System.Text;
    using System.Web;
    using System.Web.Security;
    using System.Web.UI;
    using System.Web.UI.WebControls;
    using System.Web.UI.WebControls.WebParts;
    using System.Web.UI.HtmlControls;
    using System.Collections.Generic;
    using System.Data.SqlClient;
    using System.Data;
    using System.Configuration;
    using System.Web;
    using System.Web.UI;
    using System.IO.Compression;
    using System.Text.RegularExpressions;
    using System.Xml;
    using System.Globalization;
    //using Ionic.Zip;
    using System.Net;
    using System.Net.Http;
    using System.Collections.Generic;
    using System.Data.OleDb;
    //using Microsoft.VisualBasic;
    using System.Text; // This was needed to make ASCIIEncoding function
    using System.Security.Cryptography; // This was needed to make everything related to MD5 function
    using Outlook = Microsoft.Office.Interop.Outlook;

    namespace Validate_File1
    {
    class Program
    {
    static void Main(string[] args)
    {
    string Email = "", s_Partner = "", File0, File1, File1b, File2, File3, F4, Call_Sign, Line0= "", Line1 = "", Line2 = "", Line3 = "", Line_Hold = "", ftx_Line1 = "", eqd_Line1 = "", cta_Line1 = "", Ver0 = "", line = "", Str0, Str1 = "";
    int Pos0, Pos1, Pos2, Pos3, Pos4, Pos5, Pos6, Pos7, Pos8, Pos9, Pos10 = 0, Pos11 = 0, Pos12, Pos13, Pos14, Pos15, Pos_Hold0, Pos_Hold1, Sep_Count, Len0, UNT_pos, Tot_line, Total_Line1 = 0, eqd2_line_cnt = 0;
    bool UNB_Exist, UNZ_Exist, UNT_Exist, NAD_Exist = false, Voy_Ref0, Voy_Ref1, gid_Line, ftx_Line, eqd_Line, eqd2_line = false, eqd3_line = false, cta_Line, cta_OK, codeco = false, Found0, BGM_line = false, TDT_line = false, LOC_line = false;
    bool allowappend = true;
    Outlook.MailItem mailItem = null;

            //File0 = "C:/cmp3g/CODECO_ERROR_a/" + args[0] + "/" + args[1];
            File0 = "";
            //File1 = "C:/cmp3g/CODECO_ERROR_a/Error" + Format(Now, "mmss") + ".txt"
            File1 = "C:/cmp3g/CODECO_ERROR_a/Error.txt";
            File1b = "C:/cmp3g/CODECO_ERROR_a/Error2.txt";
            File2 = "C:/cmp3g/CODECO_ERROR_a/Temp.txt";
            File3 = "C:/cmp3g/CODECO_ERROR_a/List0.txt";
            F4 = "C:/cmp3g/CODECO_ERROR_a/List7.txt";
            List<string> l7 = new List<string>();
    
            using (StreamReader sr2 = new StreamReader(@"C:/cmp3g/CODECO_ERROR_a/List7.txt", Encoding.Default))
                ////using (StreamReader sr2 = new StreamReader(@"e:/Upd_China_city.sql", Encoding.Default))
                //{
                while ((line = sr2.ReadLine()) != null)
                {
                    //        //if (line.Trim() == "")
                    //        //{
    
                    //        //}
                    //        //else
                    //        {
                    //            //str.Add(line.Trim().Substring(6));
                    l7.Add(line);
                    //            //str.Add((line+"").Substring(5));
                    //        }
                }
    
            Outlook.Application outlookApp = new Outlook.Application();
            if (File.Exists(@File1b))
            {
                File.Delete(@File1b);
            }
            if (File.Exists(@File2))
            {
                File.Delete(@File2);
            }
    
            //File.Copy(@File0, @File2);
    
            Sep_Count = 0; UNT_pos = 0; Tot_line = 0;
            UNB_Exist = false; UNT_Exist = false; UNZ_Exist = false; Voy_Ref0 = false; Voy_Ref1 = false; gid_Line = false; ftx_Line = false; eqd_Line = false; cta_Line = false; cta_OK = false;
            try
            {
                using (StreamReader sr = new StreamReader(@File1, Encoding.Default))
                {
                    while ((Line0 = sr.ReadLine()) != null)
                    {
                        Total_Line1++;
                        Pos0 = Line0.IndexOf("for partner code '"); Pos1 = Line0.IndexOf("'", Pos0 + 18);
                        if (Pos0 > 0 && Pos1 > 0)
                        {
                            if (Pos1 - Pos0 - 17 > 1)
                            {
                                if (Pos1 - Pos0 - 19 > 0)
                                {
                                    Str0 = Line0.Substring(Pos0 + 18, Pos1 - Pos0 - 19); Pos2 = Str0.Trim().Length;
                                }
                                else
                                {
                                    Str0 = "";Pos2 = 1;
                                }
                                using (StreamWriter sw = new StreamWriter(@File1b, allowappend, Encoding.Unicode))
                                {
                                    sw.WriteLine("bb");
                                }
                                for (int j = 0; j < l7.Count(); j++)
                                {
                                    if (l7[j].Trim().Length >= Str0.Trim().Length)
                                    {
                                        if (l7[j].Substring(0, Pos2) == Str0)
                                        {
                                            using (StreamWriter sw = new StreamWriter(@File1b, allowappend, Encoding.Unicode))
                                            {
                                                sw.WriteLine("cc");
                                            }
                                            Pos3 = l7[j].IndexOf(",,"); Pos4 = l7[j].Trim().Length;
                                            using (StreamWriter sw = new StreamWriter(@File1b, allowappend, Encoding.Unicode))
                                            {
                                                sw.WriteLine("dd");
                                            }
                                            if (Pos3 > 0)
                                            {
                                                mailItem = (Outlook.MailItem)outlookApp.CreateItem(Outlook.OlItemType.olMailItem);
    
                                                if (Pos4 - 3 - Pos3 > 0)
                                                    Email = l7[j].Substring(Pos3 + 2, Pos4 - 3 - Pos3);
    
                                                if (mailItem.EntryID != null)
                                                {
                                                    mailItem.Subject = "Coarri Codeco Issue ";
                                                    //mailItem.Send();
                                                }
    
                                            }
                                        }
                                    }
                                }
                            }
                        }
                        else
                        {
                            if (mailItem == null)
                                mailItem = (Outlook.MailItem)outlookApp.CreateItem(Outlook.OlItemType.olMailItem);
                            if (mailItem.EntryID != null)
                            {
                                mailItem.HTMLBody = mailItem.HTMLBody + Line0;
                                //mailItem.Send();
                            }
    
                        }
                        //using (StreamWriter sw = new StreamWriter(@File1, allowappend, Encoding.Unicode))
                        //{
                        //    sw.WriteLine("xxx");
                        //    sw.WriteLine(Line0);
                        //    sw.WriteLine("");
                        //}
                        Pos1 = Line0.IndexOf("'", Pos0 + 1);
    
                        Pos_Hold0 = Line0.IndexOf("'");
                        Pos_Hold1 = Line0.IndexOf("'", Pos_Hold0 + 1);
    
                        Line_Hold = Line0;
                    }
                }
            }
            catch (Exception e)
            {
                using (StreamWriter sw = new StreamWriter(@File1b, allowappend, Encoding.Unicode))
                {
                    //sw.WriteLine("Error happens due to file - '" + File0 + "' with detail:  Error with Stacktrace --> " + e.Message + " " + e.StackTrace+Line0);
                    sw.WriteLine(e.StackTrace);
                }
    
            }
            finally
            {
    
            }
    
        }
    }
    

    }


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.