Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/wpf/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# XAML解析异常-xmlns:x=";http://schemas.microsoft.com/winfx/2006/xaml"_C#_Wpf_Xaml - Fatal编程技术网

C# XAML解析异常-xmlns:x=";http://schemas.microsoft.com/winfx/2006/xaml"

C# XAML解析异常-xmlns:x=";http://schemas.microsoft.com/winfx/2006/xaml",c#,wpf,xaml,C#,Wpf,Xaml,昨晚我在我的电脑上用VS2010 Ultimate做了一个WPF项目 我刚刚用VS C#2010 Express在我的上网本上打开了它 当我尝试运行它时,会抛出一个XAML解析异常,它告诉我行: xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 这就是问题所在。我看不出有什么问题,我从来没有改变过它,它看起来就是它应该是的样子 错误: 'The invocation of the constructor on type 'WpfApp

昨晚我在我的电脑上用VS2010 Ultimate做了一个WPF项目

我刚刚用VS C#2010 Express在我的上网本上打开了它

当我尝试运行它时,会抛出一个XAML解析异常,它告诉我行:

xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
这就是问题所在。我看不出有什么问题,我从来没有改变过它,它看起来就是它应该是的样子

错误:

'The invocation of the constructor on type 'WpfApplication1.MainWindow' that matches the specified binding constraints threw an exception.' Line number '3' and line position '9'.
完整XAML:

<Window x:Class="WpfApplication1.MainWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="Camera" Height="550" Width="826" Background="#ddd" ResizeMode="NoResize" WindowStyle="None" MouseLeftButtonDown="Window_MouseLeftButtonDown" BorderBrush="#FF8D8D8D" BorderThickness="2" >
<Window.Resources>
    <Style TargetType="{x:Type Button}">
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Button}">
                   <ContentPresenter
              Margin="{TemplateBinding Control.Padding}"
              HorizontalAlignment="{TemplateBinding Control.HorizontalContentAlignment}"
              VerticalAlignment="{TemplateBinding Control.VerticalContentAlignment}"
              SnapsToDevicePixels="{TemplateBinding UIElement.SnapsToDevicePixels}"
              ContentTemplate="{TemplateBinding ContentControl.ContentTemplate}"
              RecognizesAccessKey="True"
              Content="{TemplateBinding ContentControl.Content}" />
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
</Window.Resources>
<Grid Width="830" Height="510">
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="132" />
        <ColumnDefinition Width="698*" />
    </Grid.ColumnDefinitions>
    <Grid.RowDefinitions>
        <RowDefinition Height="29" />
        <RowDefinition Height="319" />
        <RowDefinition Height="121" />
        <RowDefinition Height="16" />
        <RowDefinition Height="25*" />
    </Grid.RowDefinitions>
    <ComboBox Name="PortNames" Height="23" HorizontalAlignment="Left" VerticalAlignment="Top" Width="120" SelectionChanged="PortNames_SelectionChanged" Margin="12,6,0,0" />
    <Ellipse Grid.Row="2"  Height="120" HorizontalAlignment="Left" Name="ellipse1" StrokeThickness="6" VerticalAlignment="Top" Width="120" MouseLeftButtonDown="ellipse1_MouseLeftButtonDown" Margin="12,0,0,0">
        <Ellipse.Fill>
            <LinearGradientBrush EndPoint="1,1" StartPoint="0,0">
                <GradientStop Color="#89FF0000" Offset="0" />
                <GradientStop Color="Red" Offset="1" />
            </LinearGradientBrush>
        </Ellipse.Fill>
        <Ellipse.Stroke>
            <LinearGradientBrush EndPoint="1,1" StartPoint="0,0">
                <GradientStop Color="#FFB10000" Offset="0" />
                <GradientStop Color="#83B20707" Offset="0" />
                <GradientStop Color="#F7B00000" Offset="1" />
            </LinearGradientBrush>
        </Ellipse.Stroke>
    </Ellipse>
    <Button Content="Sync" Height="23" HorizontalAlignment="Left" Margin="57,6,0,0" Name="button1" VerticalAlignment="Top" Width="75" Click="button1_Click" Grid.Row="1" />
    <Rectangle Height="23" HorizontalAlignment="Left" Margin="12,6,0,0" Name="rectangle2" Stroke="Black" VerticalAlignment="Top" Fill="Red" Width="39" OpacityMask="#AA000000" Grid.Row="1" />
    <ProgressBar Grid.Row="4"  Height="19" HorizontalAlignment="Left" Name="progressBar1" VerticalAlignment="Top" Width="120" Margin="12,2,0,0" />
    <Rectangle Grid.RowSpan="5" Grid.Column="1" Height="500" Name="rectangle1" Stroke="#aaa" Width="660" Fill="#eee" Margin="12,5,26,5" />
    <Button Grid.Column="1" Height="18" HorizontalAlignment="Left" Margin="630,-20,0,0" Name="image1" VerticalAlignment="Top" Width="40" Click="image1_Click"><Image Stretch="Fill" Source="/PhotoProgram;component/Images/Close.png" /></Button>
    <Button Grid.Column="1" Height="18" HorizontalAlignment="Left" Margin="587,-20,0,0" Name="minimize" VerticalAlignment="Top" Width="40" Click="minimize_Click"><Image Stretch="Fill" Source="/PhotoProgram;component/Images/Minimize.png"  /></Button>
</Grid>


XAMLParseException是WPF中引发的常见异常。不幸的是,这不是很有帮助

为了帮助找出真正的错误是什么,您可以在VisualStudio中更早地启用异常报告。默认组合键为Ctrl+Alt+E。从那里,选中所有框


现在,代码中抛出的异常将在调试器中突出显示。

xaml看起来正常。这不应该有什么问题。 我想你是想得到一些数据。您是否正在尝试从应用程序中获取一些信息?如果是,则默认消息大小为65536字节。在app.config中增加该数字。
同时在运行程序时打开输出窗口,检查是否存在绑定错误。

请从参考中尝试此操作

“您需要的dll”->properties->copy to local->true(将其从false更改)


保存并清除解决方案,然后重新生成它。我认为它会起作用(对我有效)。

我有这个错误,更改异常报告似乎没有帮助

我注意到我正试图打电话:

var processClass = new ManagementClass(@"\server.domain1.co.uk\root\cimv2:Win32_Process");
其中
\server
应该是
\\server

更改此选项可以修复此问题,但如果出现一条错误消息却没有告诉您任何错误,则会非常恼人


实际上,我在wpf中未正确形成字符串的一些地方注意到了这个错误,因此这可能是一个很好的开始

这是一个常见的错误。然而,来源并不总是直截了当的。有时它和XAML本身无关。在一个例子中,我遇到了在序列化之后通过filestream将对象写入磁盘的问题。这在Win7中工作得很好,在WinXP中正好抛出了这个异常。尝试在代码中放置断点,并尝试找出导致错误的特定行。然后深入调用堆栈。干杯。谢谢窗口构造函数正在引发ArrayIndexOutOfBounds异常。这与那句台词无关。真烦人。哇,这让我的生活轻松多了。我真希望我早几个小时就发现了。原来我的问题是在SQLite查询中拼写错误SELECT。我一直认为默认情况下会突出显示这些错误。在我的自定义wpf控件中,我为依赖项属性的默认值声明了错误的类型,在CLR抛出时打开了异常之后,visual studio能够向我展示真正的问题