小编man*_*c66的帖子

如何在XamlParseException上避免整个应用程序关闭

我的应用程序是多窗口.如果发生XamlParseException,则关闭整个应用程序.

我最想做的是关闭这个错误的"负责"窗口.

你知道实现这个目标的方法吗?

一个例外情况:

System.Windows.Markup.XamlParseException: Provide value on 'System.Windows.Markup.StaticResourceHolder' threw an exception. ---> System.Exception: Cannot find resource named 'PasteCommandRef'. Resource names are case sensitive.
   at System.Windows.StaticResourceExtension.ProvideValueInternal(IServiceProvider serviceProvider, Boolean allowDeferredReference)
   at System.Windows.StaticResourceExtension.ProvideValue(IServiceProvider serviceProvider)
   at MS.Internal.Xaml.Runtime.ClrObjectRuntime.CallProvideValue(MarkupExtension me, IServiceProvider serviceProvider)
   --- End of inner exception stack trace ---
   at System.Windows.Markup.XamlReader.RewrapException(Exception e, Uri baseUri)
   at System.Windows.FrameworkTemplate.LoadTemplateXaml(XamlReader templateReader, XamlObjectWriter currentWriter)
   at System.Windows.FrameworkTemplate.LoadTemplateXaml(XamlObjectWriter objectWriter)
   at System.Windows.FrameworkTemplate.LoadOptimizedTemplateContent(DependencyObject container, IComponentConnector componentConnector, IStyleConnector styleConnector, List`1 affectedChildren, UncommonField`1 templatedNonFeChildrenField)
   at System.Windows.FrameworkTemplate.LoadContent(DependencyObject container, List`1 affectedChildren)
   at System.Windows.StyleHelper.ApplyTemplateContent(UncommonField`1 dataField, DependencyObject container, FrameworkElementFactory …

c# wpf xaml exception

5
推荐指数
1
解决办法
3481
查看次数

为什么string.Join(“”,new object [] {null,“ a”,null,“ b”})重新运行string.Empty?

我注意到string.Join(" ", new object[] { null, "a", null, "b"})退货string.Empty

注意string.Join(" ", new string[] { null, "a", null, "b"})返回a b(正如我期望的那样)

连接字符时,事情变得恶毒: string.Join(" ", new object[] { null, 'a', null, 'b'})它还会返回string.Empty

编辑:即使文档说了这件事(感谢@elgonzo),是否有合理的理由在框架中实现了这种例外?

参见https://dotnetfiddle.net/uM9SVp

c# string join object

2
推荐指数
1
解决办法
110
查看次数

标签 统计

c# ×2

exception ×1

join ×1

object ×1

string ×1

wpf ×1

xaml ×1