我正在制作WPF复本,它可以按预期工作,但仅当我在Visual Studio中运行它时才可以。
如果我导航到该文件夹并从那里运行它,它只会崩溃而没有任何消息。
这是一个视频演示:http: //youtu.be/gVONAT387VQ
在0.9之前,该应用程序运行良好。从那时起,我仅添加了一个新的Grid,开始使用Properties.Settings.Default并添加了ReadOnly文件的处理程序(因为此应用程序先读取然后写入配置文件)。这些似乎都不会导致此问题。
编辑:
发现原因。事件查看器将错误写出。
我刚刚实现的带有已处理异常的消息框的一部分:
System.Windows.Markup.XamlParseException: The invocation of the constructor on type 'DayZ_Config_Tweak_tool.MainWindow' that matches the specified binding constraint threw an exception. ---> System.FormatException: Token is not valid.
at MS.Internal.Parsers.ParseBrush(String brush, IFormatPRovider formatProvider, ITypeDescriptorContext contex)
at System.Windows.Media.Brush.Parse(String value, ITypeDescriptorContext context)
at System.Windows.Media.BrushConverter:ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, Object value)
at DayZ_Config_Tweak_Tool.MainWindow.InitializeButtons() in #Path to xaml.cs#:line 222
at DayZ_Config_Tweak_tool.MainWindow..ctor() in #Path to xaml.cs#:line 44
我的设置是十六进制颜色字符串,并且它们错过了标签标签“ 000000”而不是“#000000”。在调试运行期间,我的应用程序自动加载了“黑暗”主题,该主题在应用程序启动后立即初始化,但是一旦出于某种原因应用程序在开发环境之外运行,这种情况就不会发生。添加主题标签可解决此问题。
基本上在Devenv外部运行应用程序意味着您的Properties.Settings.Default将为空!检查并在InitializeComponent()之前加载它;解决了所有问题!
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句