Visual Studio 2015 XAML设计器视图异常

时间:2017-10-23 17:07:03

标签: xaml visual-studio-2015 designer

在我的Visual Studio 2015中,XAML设计器视图无法加载MainWindow.xaml,这对于资源来说非常大,有一个非常大的Style.xaml。 它只发生在x64配置中,当我切换到x86并重新编译时就消失了。 我得到的例外是 InvalidOperationException:必须在ShaderEffect上设置PixelShader。 堆栈跟踪不指向任何行号,并且没有列出我的代码文件,因此这是一个死胡同。 该应用运行良好,并显示MainWindow它只是设计师。 从xaml中删除某些行甚至一些空格似乎会使其加载,但只是暂时它会最终崩溃,因为&#34; System.Runtime.Remoting.RemotingException:Designer进程意外终止!&#34;。< / p>

堆栈跟踪:            在System.Windows.Media.Effects.ShaderEffect.ManualUpdateResource(Channel channel,Boolean skipOnChannelCheck)            在System.Windows.Media.Effects.ShaderEffect.UpdateResource(Channel channel,Boolean skipOnChannelCheck)            在System.Windows.Media.Effects.ShaderEffect.AddRefOnChannelCore(频道频道)            在System.Windows.Media.Effects.Effect.System.Windows.Media.Composition.DUCE.IResource.AddRefOnChannel(频道频道)            在System.Windows.Media.Visual.UpdateEffect(Channel channel,ResourceHandle handle,VisualProxyFlags flags,Boolean isOnChannel)            在System.Windows.Media.Visual.RenderRecursive(RenderContext ctx)            在System.Windows.Media.Visual.UpdateChildren(RenderContext ctx,ResourceHandle句柄)            在System.Windows.Media.Visual.RenderRecursive(RenderContext ctx)            在System.Windows.Media.Visual.UpdateChildren(RenderContext ctx,ResourceHandle句柄)            在System.Windows.Media.Visual.RenderRecursive(RenderContext ctx)            在System.Windows.Media.Visual.UpdateChildren(RenderContext ctx,ResourceHandle句柄)            在System.Windows.Media.Visual.RenderRecursive(RenderContext ctx)            在System.Windows.Media.Visual.UpdateChildren(RenderContext ctx,ResourceHandle句柄)            在System.Windows.Media.Visual.RenderRecursive(RenderContext ctx)            在System.Windows.Media.Visual.UpdateChildren(RenderContext ctx,ResourceHandle句柄)            在System.Windows.Media.Visual.RenderRecursive(RenderContext ctx)            在System.Windows.Media.Visual.UpdateChildren(RenderContext ctx,ResourceHandle句柄)            在System.Windows.Media.Visual.RenderRecursive(RenderContext ctx)            在System.Windows.Media.Visual.UpdateChildren(RenderContext ctx,ResourceHandle句柄)            在System.Windows.Media.Visual.RenderRecursive(RenderContext ctx)            在System.Windows.Media.Visual.UpdateChildren(RenderContext ctx,ResourceHandle句柄)            在System.Windows.Media.Visual.RenderRecursive(RenderContext ctx)            在System.Windows.Media.Visual.UpdateChildren(RenderContext ctx,ResourceHandle句柄)            在System.Windows.Media.Visual.RenderRecursive(RenderContext ctx)            在System.Windows.Media.Visual.UpdateChildren(RenderContext ctx,ResourceHandle句柄)            在System.Windows.Media.Visual.RenderRecursive(RenderContext ctx)            在System.Windows.Media.Visual.UpdateChildren(RenderContext ctx,ResourceHandle句柄)            在System.Windows.Media.Visual.RenderRecursive(RenderContext ctx)            在System.Windows.Media.Visual.UpdateChildren(RenderContext ctx,ResourceHandle句柄)            在System.Windows.Media.Visual.RenderRecursive(RenderContext ctx)            在System.Windows.Media.Visual.UpdateChildren(RenderContext ctx,ResourceHandle句柄)            在System.Windows.Media.Visual.RenderRecursive(RenderContext ctx)            在System.Windows.Media.Visual.UpdateChildren(RenderContext ctx,ResourceHandle句柄)            在System.Windows.Media.Visual.RenderRecursive(RenderContext ctx)            在System.Windows.Media.Visual.UpdateChildren(RenderContext ctx,ResourceHandle句柄)            在System.Windows.Media.Visual.RenderRecursive(RenderContext ctx)            在System.Windows.Media.Visual.UpdateChildren(RenderContext ctx,ResourceHandle句柄)            在System.Windows.Media.Visual.RenderRecursive(RenderContext ctx)            在System.Windows.Media.Visual.UpdateChildren(RenderContext ctx,ResourceHandle句柄)            在System.Windows.Media.Visual.RenderRecursive(RenderContext ctx)            在System.Windows.Media.Visual.UpdateChildren(RenderContext ctx,ResourceHandle句柄)            在System.Windows.Media.Visual.RenderRecursive(RenderContext ctx)            在System.Windows.Media.Visual.UpdateChildren(RenderContext ctx,ResourceHandle句柄)            在System.Windows.Media.Visual.RenderRecursive(RenderContext ctx)            在System.Windows.Media.Visual.UpdateChildren(RenderContext ctx,ResourceHandle句柄)            在System.Windows.Media.Visual.RenderRecursive(RenderContext ctx)            在System.Windows.Media.Visual.UpdateChildren(RenderContext ctx,ResourceHandle句柄)            在System.Windows.Media.Visual.RenderRecursive(RenderContext ctx)            在System.Windows.Media.Visual.UpdateChildren(RenderContext ctx,ResourceHandle句柄)            在System.Windows.Media.Visual.RenderRecursive(RenderContext ctx)            在System.Windows.Media.Visual.UpdateChildren(RenderContext ctx,ResourceHandle句柄)            在System.Windows.Media.Visual.RenderRecursive(RenderContext ctx)            在System.Windows.Media.Visual.UpdateChildren(RenderContext ctx,ResourceHandle句柄)            在System.Windows.Media.Visual.RenderRecursive(RenderContext ctx)            在System.Windows.Media.Visual.Render(RenderContext ctx,UInt32 childIndex)            在System.Windows.Media.CompositionTarget.Compile(频道频道)            在System.Windows.Media.CompositionTarget.System.Windows.Media.ICompositionTarget.Render(Boolean inResize,Channel channel)            在System.Windows.Media.MediaContext.Render(ICompositionTarget resizedCompositionTarget)            在System.Windows.Media.MediaContext.RenderMessageHandlerCore(Object resizedCompositionTarget)            在System.Windows.Media.MediaContext.RenderMessageHandler(Object resizedCompositionTarget)            在System.Windows.Threading.ExceptionWrapper.InternalRealCall(委托回调,对象args,Int32 numArgs)            at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source,Delegate callback,Object args,Int32 numArgs,Delegate catchHandler)

1 个答案:

答案 0 :(得分:0)

我在x64配置上也有相同的堆栈跟踪。如果我们不处于设计模式,我决定只应用效果来解决问题。

在我的情况下,当IsEnabled = False时,我想要显示禁用的图像。添加一个额外的触发器来检查视图模型上的NotInDesignMode属性就可以了。

<Style x:Key="GreyImage" TargetType="{x:Type Image}">
    <Style.Triggers>
        <MultiDataTrigger>
            <MultiDataTrigger.Conditions>
                <Condition Binding="{Binding RelativeSource={x:Static RelativeSource.Self}, Path=IsEnabled}" Value="False"/>
                <Condition Binding="{Binding Path=NotInDesignMode}" Value="True" />
            </MultiDataTrigger.Conditions>
            <Setter Property="Effect" >
                <Setter.Value>
                    <local:GreyscaleEffect DesaturationFactor="0.0" />
                </Setter.Value>
            </Setter>
            <Setter Property="Opacity" Value="0.5" />
        </MultiDataTrigger>
    </Style.Triggers>
</Style>

我在主窗口的构造函数中设置了NotInDesignMode,并将其作为viewmodel基类中的静态属性。

bool notInDesignMode = !DesignerProperties.GetIsInDesignMode(this);

有趣的是,如果我使用System.Windows.Media.Effects.BlurEffect,我没有收到错误。