I created a C++ dll and i want to use that dll in C#. i created three functions in dll
Initializ(),Start(),Release()
in the initialize function i am opening a log file
static __declspec(dllexport) initialize()
{
try
{
logfile lg("log.txt");
}
catch(exception e)
{
throw e.what();
}
}
after that i am calling this initialize function in C#
[DllImport("LgDll.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern void Initialize();
private void button1_Click(object sender, EventArgs e)
{
try
{
Initialize()
catch (SEHException ex)
{
MessageBox.Show(ex.Message);
}
}
}
this is my c# application where i am calling this function. now i want that if log file is not opening in dll than it throw error outside the dll and the C# application has to decide weather to continue the application or abort the application or ignore the error. please some body help me with sample C++ code. so that the C++ dll send the exception outside the dll and wait for C# app response.