Click here to Skip to main content
15,885,824 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
I made a WPF application with a colleague of mine.
Sometimes this program causes the ntdll.dll to behave strangely and makes our explorer.exe and our mmc.exe to crash.

We don't have any idea's where to go look, let alone resolve our problem.

Underneath you will find the Debug report for when mmc.exe crashed.

First-chance exception at 0x000007FEFD649E5D in explorer.exe: Microsoft C++ exception: CNLBaseException at memory location 0x000000000FEEA628.
First-chance exception at 0x000007FEFD649E5D in explorer.exe: Microsoft C++ exception: CNLBaseException at memory location 0x000000000FEEB090.
The thread 0x19ac has exited with code 0 (0x0).
The thread 0xc0c has exited with code 0 (0x0).
The thread 0x163c has exited with code 0 (0x0).
The thread 0x15b0 has exited with code 0 (0x0).
The thread 0x1fcc has exited with code 0 (0x0).
The thread 0x1b28 has exited with code 0 (0x0).
First-chance exception at 0x000007FEFD649E5D in explorer.exe: Microsoft C++ exception: CNLBaseException at memory location 0x000000000F0CA7C8.
First-chance exception at 0x000007FEFD649E5D in explorer.exe: Microsoft C++ exception: CNLBaseException at memory location 0x000000000F0CB230.
The thread 0x1430 has exited with code 0 (0x0).
The thread 0x19cc has exited with code 0 (0x0).
'explorer.exe' (Win32): Unloaded 'C:\Program Files\Microsoft Office\Office14\ONFILTER.DLL'
'explorer.exe' (Win32): Unloaded 'C:\Windows\System32\EhStorAPI.dll'
The thread 0x1470 has exited with code 0 (0x0).
First-chance exception at 0x00000000774832D0 (ntdll.dll) in mmc.exe: 0xC0000005: Access violation reading location 0x00000EA73876EA28.
First-chance exception at 0x00000000774832D0 (ntdll.dll) in mmc.exe: 0xC0000005: Access violation reading location 0x00000EA7384E95D8.
First-chance exception at 0x00000000774832D0 (ntdll.dll) in mmc.exe: 0xC0000005: Access violation reading location 0x00000AF579E6AF78.
First-chance exception at 0x00000000774832D0 (ntdll.dll) in mmc.exe: 0xC0000005: Access violation reading location 0x00000AF579E6AF78.
First-chance exception at 0x00000000774832D0 (ntdll.dll) in mmc.exe: 0xC0000005: Access violation reading location 0x00000EA7384F0668.
First-chance exception at 0x00000000774832D0 (ntdll.dll) in mmc.exe: 0xC0000005: Access violation reading location 0x00000EA75DF20D58.
First-chance exception at 0x00000000774832D0 (ntdll.dll) in mmc.exe: 0xC0000005: Access violation reading location 0x00000EA75DF20D58.
First-chance exception at 0x00000000774832D0 (ntdll.dll) in mmc.exe: 0xC0000005: Access violation reading location 0x00000EA75DF20D58.
First-chance exception at 0x00000000774832D0 (ntdll.dll) in mmc.exe: 0xC0000005: Access violation reading location 0x000002261DA97E38.
First-chance exception at 0x00000000774832D0 (ntdll.dll) in mmc.exe: 0xC0000005: Access violation reading location 0x00000EA836421048.
First-chance exception at 0x00000000774832D0 (ntdll.dll) in mmc.exe: 0xC0000005: Access violation reading location 0x00000CB73871CFA8.
First-chance exception at 0x00000000774832D0 (ntdll.dll) in mmc.exe: 0xC0000005: Access violation reading location 0x00000EA75DF20D58.
First-chance exception at 0x00000000774832D0 (ntdll.dll) in mmc.exe: 0xC0000005: Access violation reading location 0x00000EA7384F0258.
First-chance exception at 0x00000000774850B5 (ntdll.dll) in mmc.exe: 0xC0000005: Access violation writing location 0x00000000002479AF.
Unhandled exception at 0x00000000774850B5 (ntdll.dll) in mmc.exe: 0xC000041D: An unhandled exception was encountered during a user callback.


We get "Access violation writing location" on what seems the ntdll.dll (correct me if i'm wrong)

The code as requested.

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Configuration;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public string Subfolder;
        public string DocumentName = "Default.txt";
        public string DefaultFolder = Convert.ToChar(92) + "" + Convert.ToChar(92) + "bemech002m" + Convert.ToChar(92) + "BemechData2" + Convert.ToChar(92) + "ITSB" + Convert.ToChar(92) + "Service_Desk" + Convert.ToChar(92) + "_Remedy Email Reply Scripts" + Convert.ToChar(92) + "Remedy Scripts Central";
        //string DefaultFolder = Directory.GetCurrentDirectory();
        public decimal TimerCounter = 0;
        public decimal CopyRunning = 0;
        public string ValueCopy;
        public decimal Buttonamount = 0;
        public string Button1Text = "none";
        public string Button2Text = "none";
        public string Button3Text = "none";
        public string Button4Text = "none";
        public string Button5Text = "none";
        public string AddAgentName = "0";
        public string AddOverView = "0";
        public string SubjectLine = "Update on ticket: ";
        public string UserName = "0";
        public static string R7 = "0";
        public static string R8 = "0";
        public static int TimeR7 = 100;
        public static int TimeR8 = 300;
        public int TimeoutT = 0;
        public DateTime WaitTemp;

        public Form1()
        {
            InitializeComponent();
            GetUserName();
            LoadConfig();
            CopyBar.Hide();
            LoadButtons();
            RefreshList();
            RefreshForm();
        }

        // -----------------------------startup functions -------------------------------------------------



        public void GetUserName()
        {
            UserName = System.DirectoryServices.AccountManagement.UserPrincipal.Current.DistinguishedName;
            int CurrentValueLeft = 2;
            string CurrentValue = "a";
            string UserNameLeft = UserName;
            UserName = "";

            while (CurrentValue != ",")
            {
                CurrentValueLeft = CurrentValueLeft + 1;
                CurrentValue = UserNameLeft.Substring(CurrentValueLeft, 1);
                if (CurrentValue != ",")
	            {
                    UserName = UserName + CurrentValue;
	            }
                
            }
        }

        public void LoadConfig()
        {
            AddAgentName = System.Configuration.ConfigurationSettings.AppSettings["KeyAddAgentName"];
            if (AddAgentName == "1")
            {
                AgentNameMenuItem.Checked = true;
            }
            AddOverView = System.Configuration.ConfigurationSettings.AppSettings["KeyAddOverView"];
            if (AddOverView == "1")
            {
                SignatureMenuItem.Checked = true;
            }
            R7 = System.Configuration.ConfigurationSettings.AppSettings["KeyRemedy7"];
            R8 = System.Configuration.ConfigurationSettings.AppSettings["KeyRemedy8"];
            TimeR7 = Convert.ToInt16(System.Configuration.ConfigurationSettings.AppSettings["KeyR7Time"]);
            TimeR8 = Convert.ToInt16(System.Configuration.ConfigurationSettings.AppSettings["KeyR8Time"]);
            if (R7 == "1")
            {
                Remedy7MenuItem.Checked = true;
                Remedy8MenuItem.Checked = false;
                R8 = "0";
            }
            else
            {
                if (R8 == "1")
                {
                    Remedy7MenuItem.Checked = false;
                    Remedy8MenuItem.Checked = true;
                    R7 = "0";
                }
                else
                {
                    R7 = "1";
                    R8 = "0";
                    Remedy7MenuItem.Checked = true;
                    Remedy8MenuItem.Checked = false;
                }
            }

            return;
        }

        public void LoadButtons()
        {
            ButtonL1.Hide();
            ButtonL2.Hide();
            ButtonL3.Hide();
            ButtonL4.Hide();
            ButtonL5.Hide();
            ListTemplate.Items.Clear();
            try
            {
                string Connectiepath = DefaultFolder + Convert.ToChar(92) + "Templates";
                string[] Dirlistarray = Directory.GetDirectories(@Connectiepath);
                List<string> DirNames = new List<string>();
                foreach (string DirName in Dirlistarray)
                {
                    if (Button1Text == "none")
                    {
                        Button1Text = Path.GetFileName(DirName);
                        ++Buttonamount;
                        ButtonL1.Show();
                        ButtonL1.Text = Button1Text;
                        Subfolder = Button1Text;
                        this.ButtonL1.BackColor = Color.PowderBlue;
                        this.ButtonL2.BackColor = System.Drawing.SystemColors.Control;
                        this.ButtonL3.BackColor = System.Drawing.SystemColors.Control;
                        this.ButtonL4.BackColor = System.Drawing.SystemColors.Control;
                        this.ButtonL5.BackColor = System.Drawing.SystemColors.Control;
                    }
                    else
                    {
                        if (Button2Text == "none")
                        {
                            Button2Text = Path.GetFileName(DirName);
                            ++Buttonamount;
                            ButtonL2.Show();
                            ButtonL2.Text = Button2Text;
                        }
                        else
                        {
                            if (Button3Text == "none")
                            {
                                Button3Text = Path.GetFileName(DirName);
                                ++Buttonamount;
                                ButtonL3.Show();
                                ButtonL3.Text = Button3Text;
                            }
                            else
                            {
                                if (Button4Text == "none")
                                {
                                    Button4Text = Path.GetFileName(DirName);
                                    ++Buttonamount;
                                    ButtonL4.Show();
                                    ButtonL4.Text = Button4Text;
                                }
                                else
                                {
                                    if (Button5Text == "none")
                                    {
                                        Button5Text = Path.GetFileName(DirName);
                                        ++Buttonamount;
                                        ButtonL5.Show();
                                        ButtonL5.Text = Button5Text;
                                    }
                                    else
                                    {
                                        return;
                                    }
                                }
                            }
                        }
                    }

                }


            }
            catch (DirectoryNotFoundException)
            {
                textBox1.Text = "--- template folder issue ---";
                return;
            }
            catch (FileNotFoundException)
            {
                textBox1.Text = "--- Correct template not found ---";
                return;
            }
            catch (IOException)
            {
                textBox1.Text = "--- No templates found ---";
                return;
            }
            catch (Exception)
            {
                textBox1.Text = "--- template folder issue ---";
                return;
            }
            
        }


        // -----------------------------public functions -------------------------------------------------

         private void ListTemplate_SelectedIndexChanged(object sender, EventArgs e)
         {
             DocumentName = ListTemplate.SelectedItem.ToString();
             RefreshForm();
         }

         public void RefreshForm()
        {
            try
            {
                string Connectiepath = DefaultFolder + Convert.ToChar(92) + "Templates" + Convert.ToChar(92) + Subfolder + Convert.ToChar(92) + DocumentName;
                string ConnectiepathHD = DefaultFolder + Convert.ToChar(92) + "SD Signature.txt";
                string ConnectiepathHDN1 = DefaultFolder + Convert.ToChar(92) + "SD Greeting-1.txt";
                string ConnectiepathHDN2 = DefaultFolder + Convert.ToChar(92) + "SD Greeting-2.txt";
                if (AddAgentName == "1")
                {
                    textBox1.Text = File.ReadAllText(@Connectiepath) + File.ReadAllText(@ConnectiepathHDN1) + UserName + File.ReadAllText(@ConnectiepathHDN2);
                }
                else
                {
                    textBox1.Text = File.ReadAllText(@Connectiepath) + File.ReadAllText(@ConnectiepathHD);
                }
                RefreshSubject();
            }
            catch (DirectoryNotFoundException)
            {
                textBox1.Text = "--- template folder issue ---";
                return;
            }
            catch (FileNotFoundException)
            {
                textBox1.Text = "--- Correct template not found ---";
                return;
            }
            catch (IOException)
            {
                textBox1.Text = "--- Templates not found ---";
                return;
            }
            catch (Exception)
            {
                textBox1.Text = "--- template folder issue ---";
                return;
            }
        }
        public void RefreshSubject()
        {
            try
            {
                string ConnectiepathSubject = DefaultFolder + Convert.ToChar(92) + "Subjects" + Convert.ToChar(92) + Subfolder + Convert.ToChar(92) + DocumentName;
                SubjectLine = File.ReadAllText(@ConnectiepathSubject);
            }
            catch (DirectoryNotFoundException)
            {
                SubjectLine = "Update on ticket: ";
                return;
            }
            catch (FileNotFoundException)
            {
                SubjectLine = "Update on ticket: ";
                return;
            }
            catch (IOException)
            {
                SubjectLine = "Update on ticket: ";
                return;
            }
            catch (Exception)
            {
                SubjectLine = "Update on ticket: ";
                return;
            }
        }

        public void RefreshList()
        {
            ListTemplate.Items.Clear();
            try
            {
                string Connectiepath = DefaultFolder + Convert.ToChar(92) + "Templates" + Convert.ToChar(92) + Subfolder;
                string FileSearch = "*.txt";
                string[] Filelistarray = Directory.GetFiles(@Connectiepath, FileSearch);
                List<string> fileNames = new List<string>();
                foreach (string FileName in Filelistarray)
                {
                    string filenameWithoutPath = Path.GetFileName(FileName);
                    fileNames.Add(filenameWithoutPath);
                }
                ListTemplate.Items.AddRange(fileNames.ToArray());

            }
            catch (DirectoryNotFoundException)
            {
                textBox1.Text = "--- template folder issue ---";
                return;
            }
            catch (UnauthorizedAccessException UAEx)
            {
                Console.WriteLine(UAEx.Message);
                return;
            }
            catch (PathTooLongException PathEx)
            {
                Console.WriteLine(PathEx.Message);
                return;
            }
            catch (FileNotFoundException)
            {
                textBox1.Text = "--- Correct template not found ---";
                return;
            }
            catch (IOException)
            {
                textBox1.Text = "--- No templates found ---";
                return;
            }
            catch (Exception)
            {
                textBox1.Text = "--- template folder issue ---";
                return;
            }
        }


        private void CheckINC()
        {
            Clipboard.Clear();
            SendKeys.SendWait("{END}");
            SendKeys.SendWait("+({HOME})");
            TimeOut(50);
            SendKeys.SendWait("^({C})");
            ValueCopy = Convert.ToString(Clipboard.GetText());
            if (ValueCopy.StartsWith("INC"))
            {
                if (R7 == "1")
                {
                    CopyTemplateR7();
                }
                else
                {
                    if (R8 == "1")
                    {
                        CopyTemplateR8();
                    }
                }
                
            }
            else
            {
                TimerText.Text = "Correct field not found";
                StartDoneTimer();

            }
        }

        private void CopyTemplateR8()
        {
            MessageBox.Show("Thank you for flying with Remedy 8 support crew. The option you are using should be invalid to you, as nobody has Remedy 8 access. ~ Thank you, please come again");
            
            TimerText.Text = "Done";
            Clipboard.Clear();
            StartDoneTimer();
        }
        private void CopyTemplateR7()
        {
            TimerText.Text = "Copying";
            SendKeys.SendWait("{HOME}");
            SendKeys.SendWait("" + SubjectLine + " ");
            
            WaitTemp = TimeOut(TimeR7);
            Application.DoEvents();

            SendKeys.SendWait("{TAB}");
            SendKeys.SendWait("Regarding ticket: " + ValueCopy + "");
            SendKeys.SendWait("{ENTER}");

            WaitTemp = TimeOut(TimeR7);
            Application.DoEvents();

            SendKeys.SendWait("Summary: ");
            SendKeys.SendWait("{TAB}{TAB}{TAB}");

            WaitTemp = TimeOut(TimeR7);
            Application.DoEvents();
            
            SendKeys.SendWait("{ENTER}");

            WaitTemp = TimeOut(TimeR7);
            Application.DoEvents();
            
            SendKeys.SendWait("+{TAB}+{TAB}+{TAB}");
            SendKeys.SendWait("{ENTER}{ENTER}");

            WaitTemp = TimeOut(TimeR7);
            Application.DoEvents();

            textBox1.SelectAll();
            WaitTemp = TimeOut(TimeR7);
            Application.DoEvents();
            textBox1.Copy();
            WaitTemp = TimeOut(TimeR7);
            Application.DoEvents();
            SendKeys.SendWait("^{V}");
            WaitTemp = TimeOut(TimeR7);
            Application.DoEvents();

            if (AddOverView == "1")
            {
                SendKeys.SendWait("{ENTER}{ENTER}{ENTER}{ENTER}{ENTER}");
                SendKeys.SendWait("{TAB}{TAB}{TAB}");
                SendKeys.SendWait("{ENTER}");
                SendKeys.SendWait("+{TAB}+{TAB}+{TAB}");
                SendKeys.SendWait("{ENTER}{ENTER}");
                SendKeys.SendWait("{TAB}{TAB}{TAB}{TAB}");
                SendKeys.SendWait("{ENTER}");
                SendKeys.SendWait("+{TAB}+{TAB}+{TAB}+{TAB}");
            }


            TimerText.Text = "Done";
            Clipboard.Clear();
            StartDoneTimer();
        }

        // -----------------------------Timers -------------------------------------------------

        private void StartTimer()
        {
            TimerCounter = 4;
            button2.Text = "Cancel";
            TimerText.Text = "Starting in " + TimerCounter.ToString() + " ...";
            timer1.Start();
        }

        private void timer1_Tick(object sender, EventArgs e)
        {
            if (TimerCounter == 0)
            {
                TimerText.Text = "Running ...";
                CopyRunning = 1;
                CopyBar.Show();
                timer1.Stop();
                CheckINC();
            }
            else
            {
                TimerText.Text = "Starting in " + Convert.ToString(TimerCounter) + " ...";
                TimerCounter = --TimerCounter;
            }

        }

        private void StartDoneTimer()
        {
            CopyRunning = 0;
            TimerCounter = 3;
            button2.Text = "Reset";
            timer2.Start();
        }

        private void timer2_Tick(object sender, EventArgs e)
        {
            if (TimerCounter == 0)
            {
                TimerText.Text = "Ready";
                CopyBar.Hide();
                timer2.Stop();
            }
            else
            {
                TimerCounter = --TimerCounter;
            }

        }
        public static DateTime TimeOut(int a)
        {
            System.DateTime ThisMoment  = System.DateTime.Now;
            System.TimeSpan duration    = new System.TimeSpan( 0, 0, 0, 0, a ) ;
            System.DateTime AfterWards  = ThisMoment.Add( duration );
            
            
            while ( AfterWards >= ThisMoment  )
            {
                    System.Windows.Forms.Application.DoEvents() ;
                    ThisMoment = System.DateTime.Now            ;
            }

            return System.DateTime.Now;
        }

       
        // -----------------------------buttons -------------------------------------------------

        private void Terminate_Click(object sender, EventArgs e)
        {
            Close();
        }

        private void Launch_Click(object sender, EventArgs e)
        {
            StartTimer();
        }

        private void Reset_Click(object sender, EventArgs e)
        {
            if (TimerCounter == 0)
            {
                if (CopyRunning == 0)
                {
                    timer1.Stop();
                    button2.Text = "Reset";
                    textBox1.Clear();
                    TimerText.Text = "Ready";
                    CopyBar.Hide();
                }
                else
                {
                    timer1.Stop();
                    TimerText.Text = "Stopped";
                    TimerCounter = 0;
                    button2.Text = "Reset";
                    CopyBar.Hide();
                }
            }
            else
            {
                timer1.Stop();
                TimerText.Text = "Stopped";
                TimerCounter = 0;
                button2.Text = "Reset";
                CopyBar.Hide();
            }

        }

        private void ButtonL1_Click(object sender, EventArgs e)
        {
            Subfolder = Button1Text;
            this.ButtonL1.BackColor = Color.PowderBlue;
            this.ButtonL2.BackColor = System.Drawing.SystemColors.Control;
            this.ButtonL3.BackColor = System.Drawing.SystemColors.Control;
            this.ButtonL4.BackColor = System.Drawing.SystemColors.Control;
            this.ButtonL5.BackColor = System.Drawing.SystemColors.Control;
            RefreshList();
            RefreshForm();
        }

        private void ButtonL2_Click(object sender, EventArgs e)
        {
            Subfolder = Button2Text;
            this.ButtonL1.BackColor = System.Drawing.SystemColors.Control;
            this.ButtonL2.BackColor = Color.PowderBlue;
            this.ButtonL3.BackColor = System.Drawing.SystemColors.Control;
            this.ButtonL4.BackColor = System.Drawing.SystemColors.Control;
            this.ButtonL5.BackColor = System.Drawing.SystemColors.Control;
            RefreshList();
            RefreshForm();
        }

        private void ButtonL3_Click(object sender, EventArgs e)
        {
            Subfolder = Button3Text;
            this.ButtonL1.BackColor = System.Drawing.SystemColors.Control;
            this.ButtonL2.BackColor = System.Drawing.SystemColors.Control;
            this.ButtonL3.BackColor = Color.PowderBlue;
            this.ButtonL4.BackColor = System.Drawing.SystemColors.Control;
            this.ButtonL5.BackColor = System.Drawing.SystemColors.Control;
            RefreshList();
            RefreshForm();
        }

        private void ButtonL4_Click(object sender, EventArgs e)
        {
            Subfolder = Button4Text;
            this.ButtonL1.BackColor = System.Drawing.SystemColors.Control;
            this.ButtonL2.BackColor = System.Drawing.SystemColors.Control;
            this.ButtonL3.BackColor = System.Drawing.SystemColors.Control;
            this.ButtonL4.BackColor = Color.PowderBlue;
            this.ButtonL5.BackColor = System.Drawing.SystemColors.Control;
            RefreshList();
            RefreshForm();
        }

        private void ButtonL5_Click(object sender, EventArgs e)
        {
            Subfolder = Button5Text;
            this.ButtonL1.BackColor = System.Drawing.SystemColors.Control;
            this.ButtonL2.BackColor = System.Drawing.SystemColors.Control;
            this.ButtonL3.BackColor = System.Drawing.SystemColors.Control;
            this.ButtonL4.BackColor = System.Drawing.SystemColors.Control;
            this.ButtonL5.BackColor = Color.PowderBlue;
            RefreshList();
            RefreshForm();
        }

        // -----------------------------Menu Items -------------------------------------------------

        private void copyrightToolStripMenuItem_Click(object sender, EventArgs e)
        {
            About Form3 = new About();
            Form3.Show();
        }
        private void helpToolStripMenuItem_Click(object sender, EventArgs e)
        {
            string HelpFile = DefaultFolder + Convert.ToChar(92) + "Quick guide.pdf";
            try
            {
                System.Diagnostics.Process.Start(@HelpFile);
            }
            catch (Exception)
            {
                MessageBox.Show("Quick Guide.pdf not found! - Please ask Big Bird.");
                return;
            }
            
        }

        private void SignatureMenuItem_Click(object sender, EventArgs e)
        {
            if (SignatureMenuItem.Checked == true)
            {
                SignatureMenuItem.Checked = false;
                AddOverView = "0";
            }
            else
            {
                SignatureMenuItem.Checked = true;
                AddOverView = "1";
            }
        }

        private void AgentNameMenuItem_Click(object sender, EventArgs e)
        {
            if (AgentNameMenuItem.Checked == true)
            {
                AgentNameMenuItem.Checked = false;
                AddAgentName = "0";
                RefreshForm();
            }
            else
            {
                AgentNameMenuItem.Checked = true;
                AddAgentName = "1";
                RefreshForm();
            }
        }

        private void Remedy7MenuItem_Click(object sender, EventArgs e)
        {
            Remedy7MenuItem.Checked = true;
            Remedy8MenuItem.Checked = false;
            R7 = "1";
            R8 = "0";
        }

        private void Remedy8MenuItem_Click(object sender, EventArgs e)
        {
            Remedy7MenuItem.Checked = false;
            Remedy8MenuItem.Checked = true;
            R7 = "0";
            R8 = "1";
        }

        private void changeLocalSettingsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            SettingsForm Form2 = new SettingsForm();
            Form2.WaitR7 = TimeR7;
            Form2.WaitR8 = TimeR8;
            Form2.Show(Form1.ActiveForm);
        }

    }

    //Created by Wim Bosmans - Axel Melis
    //supervision by Ilse Clijsters
}
//}




Many thanks!
Posted
Updated 30-May-13 22:04pm
v2
Comments
Sergey Alexandrovich Kryukov 30-May-13 12:19pm    
Excuse me, but what's the use? You gave as the debug report without the code sample...
—SA
Nomardus 31-May-13 5:45am    
Uploaded the code as requested ;)
Sergey Alexandrovich Kryukov 31-May-13 8:08am    
Oh... could you also indicate the line where the exception is thrown? This is important.

From the first glance, the code has problems, such as pretty severe lack of reuse and too local handling of exceptions. You could get rid of local handling of exceptions (at lest for debugging time), which is easy, and catch all exceptions up the stack (a must anyway). If forms, it should be done in a special handler of the main event loop:

http://www.codeproject.com/Answers/237363/Error-Logging-and-Screen-Shot#answer2
http://www.codeproject.com/Answers/139319/Catching-an-Exception#answer2

Then you would be able to see the exception's propagation path...

Is that clear?

—SA
Nomardus 31-May-13 8:23am    
Well, I have no idea which line this is, since it doesn't ahppen when we are debugging, it only happens when we run the exe.
Sergey Alexandrovich Kryukov 31-May-13 8:29am    
Above, I actually just explained how to find it out. Oh, yes, you also should enable debugging information (compile predefined Debug configuration) and output Exception.StackTrace. This is just a string, but it will show the whole path of propagation of an exception from the point of throwing to the point of catch, with line numbers... Then you can find ends. How about that?
—SA

1 solution

Seems like we found what was wrong.
We had to many Clipboard.clear(); in the program and the computers just couldn't handle it anymore.
We took them out and we are now running it without problems for 2 days.
 
Share this answer
 
Comments
AlphaDeltaTheta 4-Jun-13 12:23pm    
You got it then ... nice to know. But I didn't imagine this!!

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