|The problem was in the unmanaged DLL. But I really learnt a great deal about other topics such as BackgroundWorkers and TPL. Thanks all.
Hello There. I have this small DLL that takes
output_name as parameters. It opens the input file, reads it and produces output file with the specified name after some processing.
I then call this function from C#. First time I call it, it runs fine. But second time around, it throws this exception
An unhandled exception of System.AccessViolationException occured in CSharpProgram.exe.<br />
Attempted to read or write protected memory.<br />
Here is what I am trying.
[DllImport("MyDll.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern int Call_Dll_Main(string input, string output);
private void Button_Click(object sender, EventArgs ea)
new System.Threading.Thread(new System.Threading.ThreadStart(Call_Dll_Function)).Start()
private void Call_Dll_Function()
int nResult = Call_Dll_Main(txtInputFile.Text.Trim(), txtOutputFile.Text.Trim());
What could be wrong? What am I missing here? Thanks for any input.
modified 14-Jul-16 11:34am.