My program exists suddenly, and I cannot find the cause, but I know which parts of the code are causing this problem. I will try to explain what happens ...
First of all, I use the following namespaces in my window form in addition to the general ones:
using System.Diagnostics;
using System.IO;
using System.Data.OleDb;
I have a custom function that retrieves the current identifier of an auto-increment string by searching for the maximum ID and incrementing it by one:
void getCurrentQuestionNo()
{
classDataLayer DL = new classDataLayer();
OleDbCommand cmd = new OleDbCommand();
cmd.CommandText = "SELECT MAX([questionID]) FROM questions";
DataSet ds = DL.select(cmd);
questionNo = Convert.ToInt32(ds.Tables[0].Rows[0][0]) + 1;
}
This function is run inside the form_load function to set a global variable called questionNo for later use.
I also have the following code to open an instance of a Microsoft Word application. This code is placed inside the button click event:
try
{
File.Copy(@"Templates\EmptyQuestion.docx", @"Temp\TempQuestion.docx", true);
ProcessStartInfo startInfo = new ProcessStartInfo();
startInfo.FileName = "WINWORD.EXE";
startInfo.Arguments = @"Temp\TempQuestion.docx";
Process.Start(startInfo);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
:
No . , getCurrentQuestionNo() form_load, , . getCurrentQuestionNo() form_load, .
, getCurrentQuestionNo() form_load, , , , - , . , Stop Visual Studio IDE.
?
:
"System.IO.IOException" mscorlib.dll
"[5032] test.vshost.exe: Program Trace" 0 (0x0).
'[5032] test.vshost.exe: Managed (v4.0.30319)' -2147483645 (0x80000003).
, oleDB . :
:
OleDbConnection con1 = new OleDbConnection("Provider=Microsoft.ACE.OLEDB.12.0;Data Source=db.accdb");
OleDbCommand cmd1 = new OleDbCommand("SELECT MAX([questionID]) FROM questions", con1);
con1.Open();
txtID.Text = cmd1.ExecuteScalar().ToString();
con1.Close();
:
Process p = new Process();
p.StartInfo.FileName = "notepad.EXE";
p.Start();
. , , 1, 2 !!!
...:(
, , , "vshost.exe " , . , ntdll.dll , clr.dll.
: : StackHash_4d02