用户代码未处理来自Dll get Exception的C#User Definedexception处理

我正在使用动态c#应用程序,它将所有类从我单独创建的Dll文件链接到主应用程序,在这些文件中,当我动态连接我的dll文件时,error handling程序希望通过连接抛出错误,因为它曾经是这是我尝试做的事情

我有一个dll文件,上面有这个编码和类

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 } } 

然后我通过使用动态方法链接这个DLL文件,它工作得很好但是当我尝试传递用户定义错误然后我得到错误作为unhandedexception并在dll文件中显示类,我不想处理任何exception在我的dll文件类中只需要将它们传递给下一步并在我使用它们的程序中处理它们。

这是我使用它的代码

 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 } } 

在此处输入图像描述

当我关闭上面的错误框并继续运行时,它也会显示这样的内容

在此处输入图像描述

我想我在这里得到答案,当我通过引用将我的dll链接到应用程序然后通过using指令使用它作为我的应用程序内的对象它工作正常并让我使用throwexception到应用程序throw catch语句,但是当它通过动态添加到应用程序中时,它希望我在dll中处理我的exception并解决所有问题,它不允许我通过对应用程序 using throw new exception("err")using throw new exception("err")

Evan没有错误的处理, throw new exception是可以的,但它不会允许throw catch块