我有一个 C#/.NET Winforms 应用程序,其中使用“.settings”文件存储了一些设置。因此,通过右键单击“解决方案资源管理器”中的项目并选择“属性->设置”来编辑配置。
但是,我还需要能够捕获应用程序内 SerialPort 对象引发的异常。我在网上找到了一个片段,指出
<runtime>
<legacyUnhandledExceptionPolicy enabled="1"/>
</runtime>
在 app.config 文件中添加 ... 可以解决此问题(确实如此)。但是:现在我的解决方案资源管理器中同时有“Settings.settings”和“app.config”文件,这导致一些开发人员编辑“app.config”而不是“Settings.settings”,从而造成很多混乱。是否可以使“Settings”类自动生成“legacyUnhandledExceptionPolicy”-app.config 文件?或者我还应该做什么?有什么建议吗?
I have a C#/.NET Winforms application which has some settings stored using A '.settings' file. So the configuration is edited by right-clicking the project in "Solution Explorer" and selecting "Properties->Settings".
However, I also need to be able to catch exceptions thrown by a SerialPort object inside the application. I found a snippet on the web stating that adding
<runtime>
<legacyUnhandledExceptionPolicy enabled="1"/>
</runtime>
... in the app.config file would fix this (which it did). BUT: Now a have both a "Settings.settings" and an "app.config" file in my Solution Explorer, which causes some developers to edit e.g. "app.config" and not "Settings.settings" causing much confusion. Is it possible to make the "Settings" class generate the 'legacyUnhandledExceptionPolicy'-thingy the app.config file automatically? Or what else should I do? Any suggestions?
发布评论
评论(1)
我会简单地得出结论:这是不可能完成的。
I'll simply conclude that This can't be done.