[英]Wpf ComboBox throws exception on combobox in windows 7
我在Windows 8上制作了WPF應用程序(框架4.5),該應用程序使用常規的組合框和一些其他控件。 我面臨的問題是它在Windows 7上崩潰:
A first chance exception of type System.Windows.Markup.XamlParseException occurred in PresentationFramework.dll
Additional information: 'Initialization of 'System.Windows.Controls.ComboBox' threw an exception.'
這是我的組合框XAML:
<ComboBox Name="bloodGroupList" Grid.Row="7" Grid.Column="1"
SelectedIndex="{Binding Patient.BloodGroup, Converter={StaticResource StrToBlood}, Mode=TwoWay}"
IsEnabled="{Binding IsEditing}"
VerticalAlignment="Center" Margin="5,5.5" VerticalContentAlignment="Center"
BorderThickness="0" Height="22" TabIndex="4" HorizontalContentAlignment="Stretch">
<ComboBoxItem Content="A+" />
<ComboBoxItem Content="A-" />
<ComboBoxItem Content="B+" />
<ComboBoxItem Content="B-" />
<ComboBoxItem Content="O+" />
<ComboBoxItem Content="O-" />
<ComboBoxItem Content="AB+" />
<ComboBoxItem Content="AB-" />
</ComboBox>
我在某個博客上閱讀了有關運行此修復程序NDP45-KB2750147-x64
但它說:
軟件更新KB2750147安裝向導不適用,或者被計算機上的其他狀況所阻止。 請單擊下面的鏈接以獲取更多詳細信息。
我將其放在App.xaml.cs
文件中以獲取完整的堆棧跟蹤。 這可能是解決問題的有用方法。
using System;
using System.Diagnostics;
using System.IO;
using System.Windows;
using System.Windows.Threading;
public partial class App : Application
{
void App_DispatcherUnhandledException(object sender, DispatcherUnhandledExceptionEventArgs e)
{
// All unhandled exceptions come here. A stacktrace is saved as a text file with date and time.
StackTrace st = new StackTrace(e.Exception);
string fileName = DateTime.Now.ToString().Replace('/', '-').Replace(':', '-') + " errors.txt";
fileName = @"C:\Users\Public\" + fileName;
System.Windows.MessageBox.Show("Critical Error. Closing program.\nStacktrace can be found:" + fileName);
using (var stream = new FileStream(fileName, FileMode.OpenOrCreate))
{
using (var strWrite = new StreamWriter(stream))
{
strWrite.Write(st.ToString());
}
}
if (MainWindow != null)
{
MainWindow.Close();
}
else
{
Environment.Exit(0);
}
e.Handled = true;
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.