Wpf 为什么我的XAML突然崩溃了?

Wpf 为什么我的XAML突然崩溃了?,wpf,xaml,windows-8,winrt-xaml,Wpf,Xaml,Windows 8,Winrt Xaml,我在项目中创建的文件夹(“视图”)中为项目添加了一个“基本页面” 起初一切正常,但“突然”设计视图失败并显示: System.ObjectDisposedException 安全手柄已经关闭 这是XAML(我还没有在生成的默认XAML中更改任何内容): 我的申请 注意:我确实尝试过根据“TODO”(在app.xaml中)删除“appname”行,但没有任何区别。应用程序通过F6成功构建,但尝试重新加载设计器失败 第二次尝试也失败了,这次是使用一个空白的xaml页面,然后粘贴在我用Kaxaml

我在项目中创建的文件夹(“视图”)中为项目添加了一个“基本页面”

起初一切正常,但“突然”设计视图失败并显示:

System.ObjectDisposedException 安全手柄已经关闭

这是XAML(我还没有在生成的默认XAML中更改任何内容):


我的申请
注意:我确实尝试过根据“TODO”(在app.xaml中)删除“appname”行,但没有任何区别。应用程序通过F6成功构建,但尝试重新加载设计器失败

第二次尝试也失败了,这次是使用一个空白的xaml页面,然后粘贴在我用Kaxaml拼凑的一些xaml中,这次是错误消息:“System.Exception” 无法注册包。(HRESULT的异常:0x80073CF6)

此XAML是(截断的):


. . .

???

我也有同样的问题,似乎问题在于VS在开始调试之前试图“部署”任何应用程序。但是Windows本地组策略可以禁止此部署。因此,您需要执行以下步骤:

  • 按Win+X打开运行对话框,键入gpedit.msc并按Enter键
  • 进入计算机配置>管理模板>Windows组件>应用程序包部署
  • 双击“允许所有受信任的应用安装”,选择“已启用”,然后选择“确定”
    这对我很有帮助。

    -这应该是XAML设计视图的座右铭。您可以创建一个单独的应用程序并将XAML粘贴到那里吗?无法注册软件包错误听起来好像您需要从“构建”菜单中选择“重建”选项。但是对于XAML。。。我们确定“:Class=“TimeAndSpaceLines.View.SectionN”不是打字错误吗?@Zack:“TimeAndSpaceLines”是解决方案名称,“View”是此文件所在的文件夹,“SectionN”是“是我添加的新页面的名称,所以不,这不是打字错误。@LeonPelletier是的,在我的例子中,我在hyper x中运行一个快照机的副本,所以这没什么大不了的。”。我为几个客户端工作,这是一个保持源代码控制、插件和环境设置完全分离的好方法。我花了大量的时间在这个bug上,不得不继续,系统恢复是最快的方法;这似乎是一个间歇性的问题(只见过一次),所以我现在暂缓做任何关于它的事情,但感谢您采取的措施,以防它再次出现。
    <common:LayoutAwarePage
        x:Name="pageRoot"
        x:Class="TimeAndSpaceLines.View.SectionPage"
        DataContext="{Binding DefaultViewModel, RelativeSource={RelativeSource Self}}"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:local="using:TimeAndSpaceLines.View"
        xmlns:common="using:TimeAndSpaceLines.Common"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        mc:Ignorable="d">
    
        <Page.Resources>
    
            <!-- TODO: Delete this line if the key AppName is declared in App.xaml -->
            <x:String x:Key="AppName">My Application</x:String>
        </Page.Resources>
    
        <!--
            This grid acts as a root panel for the page that defines two rows:
            * Row 0 contains the back button and page title
            * Row 1 contains the rest of the page layout
        -->
        <Grid Style="{StaticResource LayoutRootStyle}">
            <Grid.RowDefinitions>
                <RowDefinition Height="140"/>
                <RowDefinition Height="*"/>
            </Grid.RowDefinitions>
    
            <!-- Back button and page title -->
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto"/>
                    <ColumnDefinition Width="*"/>
                </Grid.ColumnDefinitions>
                <Button x:Name="backButton" Click="GoBack" IsEnabled="{Binding Frame.CanGoBack, ElementName=pageRoot}" Style="{StaticResource BackButtonStyle}"/>
                <TextBlock x:Name="pageTitle" Grid.Column="1" Text="{StaticResource AppName}" Style="{StaticResource PageHeaderTextStyle}"/>
            </Grid>
    
            <VisualStateManager.VisualStateGroups>
    
                <!-- Visual states reflect the application's view state -->
                <VisualStateGroup x:Name="ApplicationViewStates">
                    <VisualState x:Name="FullScreenLandscape"/>
                    <VisualState x:Name="Filled"/>
    
                    <!-- The entire page respects the narrower 100-pixel margin convention for portrait -->
                    <VisualState x:Name="FullScreenPortrait">
                        <Storyboard>
                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="backButton" Storyboard.TargetProperty="Style">
                                <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource PortraitBackButtonStyle}"/>
                            </ObjectAnimationUsingKeyFrames>
                        </Storyboard>
                    </VisualState>
    
                    <!-- The back button and title have different styles when snapped -->
                    <VisualState x:Name="Snapped">
                        <Storyboard>
                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="backButton" Storyboard.TargetProperty="Style">
                                <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource SnappedBackButtonStyle}"/>
                            </ObjectAnimationUsingKeyFrames>
                            <ObjectAnimationUsingKeyFrames Storyboard.TargetName="pageTitle" Storyboard.TargetProperty="Style">
                                <DiscreteObjectKeyFrame KeyTime="0" Value="{StaticResource SnappedPageHeaderTextStyle}"/>
                            </ObjectAnimationUsingKeyFrames>
                        </Storyboard>
                    </VisualState>
                </VisualStateGroup>
            </VisualStateManager.VisualStateGroups>
        </Grid>
    </common:LayoutAwarePage>
    
    <Page
        x:Class="TimeAndSpaceLines.View.SectionN"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:local="using:TimeAndSpaceLines.View"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        mc:Ignorable="d">
    
        <Grid MinHeight="600" ShowGridLines="True" Background="{StaticResource ApplicationPageBackgroundThemeBrush}">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="320">
                        </ColumnDefinition>
                        <ColumnDefinition MaxWidth="800">
                        </ColumnDefinition>
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                        <RowDefinition>
                        </RowDefinition>
        . . .