如果 app.config 格式错误,例如不是格式正确的 XML 文件,应用程序将无法加载。是否有任何方法可以让我知道此类问题 - 例如,如果 app.config 由于格式错误的 XML 文件而加载错误,则接收一些事件(以便我可以编写文件日志和事件日志来记录此问题)?
提前谢谢,乔治
我的代码和 app.config 看起来像这样,但没有抛出异常。
class Program
{
public static void MyEventHandler(object sender, EventArgs e)
{
return;
}
static void Main(string[] args)
{
AppDomain currentDomain = AppDomain.CurrentDomain;
currentDomain.UnhandledException += MyEventHandler;
return;
}
}
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configuration>