i am working with dynamic c# application that links all the classes into the main application from the Dll files that i create separately, in these files when i connect my dll file dynamically the error handlers want throw the errors by the connection as it used to be here is what i try to do
i have a dll file with this coding and class on it
class clsGlobles {
public object dlststus = false; // dtabase file status
public clsGlobles()
{
try
{
if (dlststus == true)
{
}
else
{
throw new Exception("Some important files are missing - Please re-install the application"); //throw this as a error and stop running the program
}
}
catch (Exception ex)
{
throw ex; //throw exception to the upper throw catch exception where i like to hand it
//Evan i use throw; instead of throw ex; i get the same result
}
}
and then i link this dll file by using dynamic method it works well but when i try to pass the user define error then i get error as unhanded exception and being show the class inside the dll file, i don't wants to handle any exception in my classes in dll file just need to pass them to the next step and handle them in the program where i use them.
here is the code where i use it
private void frmMain_Load(object sender, EventArgs e)
{
string tf = "";
tf = Application.StartupPath + "\\clsGlobles.dll";
try
{
Assembly asm = Assembly.LoadFrom(tf);
AppDomain.CurrentDomain.Load(asm.GetName());
Type type = asm.GetTypes().First(t => t.Name == "clsGlobles");
glbls = Activator.CreateInstance(type);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message.ToString()); // the error i throw in inside the dll class should come here and i could handle it from here
}
}
and when i close the above error box and continue run it also shows something like this