在Visual Studio 2008中尝试编辑UI时,WPF设计器异常 [英] WPF Designer exception while trying to edit UI in Visual studio 2008

查看:196
本文介绍了在Visual Studio 2008中尝试编辑UI时,WPF设计器异常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有VS2008与.net 3.5 SP1安装在我的机器上,我已经写了一个简单的应用程序与两个列表浏览和数据绑定,我的应用程序编译好,我可以运行它,但是当我尝试打开设计师来编辑控件,我收到以下错误。
我不知道为什么会发生这种情况。任何想法...请参阅下面的错误消息中的xaml


在Assembly'PresentationFramework中,键入'MS.Internal.Permissions.UserInitiatedNavigationPermission' 3.0.0.0,Culture = neutral,PublicKeyToken = 31bf3856ad364e35'未标记为可序列化。
在System.Runtime.Serialization.FormatterServices.InternalGetSerializableMembers(RuntimeType类型)
在System.Runtime.Serialization.FormatterServices.GetSerializableMembers(类型类型,StreamingContext上下文)
在System.Runtime.Serialization。 Formatters.Binary.WriteObjectInfo.InitMemberInfo()
在System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.InitSerialize(Object obj,ISurrogateSelector代理选择器,StreamingContext上下文,SerObjectInfoInit serObjectInfoInit,IFormatterConverter转换器,ObjectWriter objectWriter)
在System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.Serialize(Object obj,ISurrogateSelector代理选择器,StreamingContext上下文,SerObjectInfoInit serObjectInfoInit,IFormatterConverter转换器,ObjectWriter objectWriter)
在System.Runtime.Serialization.Formatters.Binary.ObjectWriter。 Write(WriteObjectInfo objectInfo,NameInfo memberNameInfo,NameInfo typeNameInfo)
在System.Runtime.Serialization.Formatters.Binary.ObjectWriter.Serialize(Object graph,Header [] inHeaders,__BinaryWriter serWriter,Boolean fCheck)
在System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serialize(Stream serializationStream ,Object Object,Header [] headers,Boolean fCheck)
在System.Runtime.Remoting.Channels.CrossAppDomainSerializer.SerializeObject(Object obj,MemoryStream stm)
在System.AppDomain.Serialize(Object o)$在System.AppDomain.MarshalObject(Object o)上的
System.Threading.CompressedStack.GetDomainCompressedStack(SafeCompressedStackHandle compressionStack,Int32索引)
$ System.Security.PermissionListSet.CreateCompressedState(CompressedStack cs,CompressedStack innerCS )
在System.Threading.CompressedStack.CompleteConstruction(CompressedStack innerCS)
在System.Threading.CompressedStack.GetCompressedStack(StackCrawlMark&在System.Security.SecurityContext.Capture(ExecutionContext currThreadEC,StackCrawlMark& stackMark)
$ System.Threading.ExecutionContext.Capture(StackCrawlMark& stackMark)
在System.Threading.ExecutionContext。 Capture()
在System.Windows.Threading.Dispatcher.BeginInvokeImpl(DispatcherPriority优先级,委托方法,Object args,Boolean isSingleParameter)
在System.Windows.Threading.Dispatcher.BeginInvoke(DispatcherPriority优先级,委托方法,Object arg)
在System.Windows.Input.CommandManager.RaiseRequerySuggested()
在System.Windows.Input.CommandManager.InvalidateRequerySuggested()
在Microsoft.Windows.Design.Interaction.Tool .TaskCollection.InsertItem(Int32索引,任务项)
在System.Collections.ObjectModel.Collection`1.Add(T项目)
在Microsoft.Windows.Design.Interaction.SelectionTool..ctor()
在MS.Internal.Providers.VSActiveToolProvider.Selectio nToolFactory.TryCreateTool [T](T&工具)
在MS.Internal.Host.ToolSubsystem.ActivateTool(ToolFactory toolFactory)
在MS.Internal.Host.ToolSubsystem..ctor(EditingContext editingContext,DesignerContext designerContext)
在MS.Internal MS.Internal.Designer.VSDesigner.Load()中的
MS.Internal.Designer.VSIsolatedDesigner.VSIsolatedView.Load()
在MS.Internal .Designer.VSIsolatedDesigner.VSIsolatedDesignerFactory.Load(IsolatedView视图)
在MS.Internal.Host.Isolation.IsolatedDesigner.BootstrapProxy.LoadDesigner(IsolatedDesignerFactory工厂,IsolatedView视图)
在MS.Internal.Host.Isolation。 IsolatedDesigner.BootstrapProxy.LoadDesigner(IsolatedDesignerFactory工厂,IsolatedView视图)
在MS.Internal.Host.Isolation.IsolatedDesigner.Load()
在MS.Internal.Designer.DesignerPane.LoadDesignerView()


XAML:








 < Grid Name =pngrid_BaseHeight =autoWidth =autoBackground =Beige > 
< Grid.ColumnDefinitions>
< ColumnDefinition Width =autoMinWidth =221>< / ColumnDefinition>
< ColumnDefinition Width =autoMinWidth =1MaxWidth =1>< / ColumnDefinition>
< ColumnDefinition Width =auto>< / ColumnDefinition>
< /Grid.ColumnDefinitions>
< Grid Name =pngrid_BaseForAllGrid.Column =0Width =autoHorizo​​ntalAlignment =LeftBackground =#FFD8E4F8>
< Grid.RowDefinitions>
< RowDefinition Height =30 */>
< RowDefinition Height =164 */>
< RowDefinition Height =35 */>
< RowDefinition Height =164 */>
< RowDefinition Height =40 */>
< /Grid.RowDefinitions>
< ListView Name =lstview_UnackGrid.Row =1Margin =2,0,0,0SelectionMode =ExtendedLostFocus =lstview_Unack_LostFocus
MouseRightButtonDown =lstview_Unack_MouseRightButtonDown> ;

< ListView.ItemContainerStyle>
< Style TargetType =ListViewItem>
< Setter Property =IsSelectedValue ={Binding Path = IsSelected,Mode = TwoWay}/>
< / Style>
< /ListView.ItemContainerStyle>
< / ListView>
< Button Grid.Row =2Horizo​​ntalAlignment =LeftMargin =24,14,0,5Name =btnFreeze> Freeze< / Button>
< Button Grid.Row =2Horizo​​ntalAlignment =LeftMargin =12,7,0,5Name =btnAcknowledgeWidth =96>确认< / Button>
< ListView Name =lstview_AckGrid.Row =3Margin =2,1,0,0LostFocus =lstview_Ack_LostFocusSelectionMode =ExtendedMouseRightButtonDown =lstview_Ack_MouseRightButtonDown>
< ListView.ItemContainerStyle>
< Style TargetType =ListViewItem>
< Setter Property =IsSelectedValue ={Binding Path = IsSelected,Mode = TwoWay}/>
< / Style>
< /ListView.ItemContainerStyle>
< / ListView>


< Button Grid.Row =4Horizo​​ntalAlignment =LeftMargin =16,12,0,7Name =ClearWidth =78>清除< / Button>
< TextBox Margin =110,6,32,5Name =FilterTextTextChanged =FilterText_TextChanged/>
< ComboBox Horizo​​ntalAlignment =LeftMargin =14,5,0,4Name =comboColumnListWidth =94/>
< / Grid>
< GridSplitter Grid.Column =1Name =gridSplitter1Width =2Horizo​​ntalContentAlignment =CenterVerticalContentAlignment =StretchHorizo​​ntalAlignment =LeftBackground =Azure/>
< Grid Name =pnGridForTreeViewGrid.Column =2Width =200Grid.ColumnSpan =2>
< my:TrinityDeviceTree x:Name =m_objDeviceTreeHeight =autoWidth =auto>

< / my:TrinityDeviceTree>
< / Grid>

< / Grid>

解决方案

我已经使用.NET 3.5 SP1测试了VS2008中的代码,如果我删除了TrinityDeviceTree的声明,那么这个设计器可以正常工作。
也许你应该che upon那个UserControl,看看是否有错误。也尝试清理您的项目和重建,有时它适用于视觉设计师的问题。


I have VS2008 with .net 3.5 SP1 installed on my machine, I have written one simple application with two listviews and databinding, My application compiles fine and I am able to run it, but when I try to open designer to edit controls, I get following error. I am not getting why this is happening. Any idea...see xaml below this error message

Type 'MS.Internal.Permissions.UserInitiatedNavigationPermission' in Assembly 'PresentationFramework, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' is not marked as serializable. at System.Runtime.Serialization.FormatterServices.InternalGetSerializableMembers(RuntimeType type) at System.Runtime.Serialization.FormatterServices.GetSerializableMembers(Type type, StreamingContext context) at System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.InitMemberInfo() at System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.InitSerialize(Object obj, ISurrogateSelector surrogateSelector, StreamingContext context, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter, ObjectWriter objectWriter) at System.Runtime.Serialization.Formatters.Binary.WriteObjectInfo.Serialize(Object obj, ISurrogateSelector surrogateSelector, StreamingContext context, SerObjectInfoInit serObjectInfoInit, IFormatterConverter converter, ObjectWriter objectWriter) at System.Runtime.Serialization.Formatters.Binary.ObjectWriter.Write(WriteObjectInfo objectInfo, NameInfo memberNameInfo, NameInfo typeNameInfo) at System.Runtime.Serialization.Formatters.Binary.ObjectWriter.Serialize(Object graph, Header[] inHeaders, __BinaryWriter serWriter, Boolean fCheck) at System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serialize(Stream serializationStream, Object graph, Header[] headers, Boolean fCheck) at System.Runtime.Remoting.Channels.CrossAppDomainSerializer.SerializeObject(Object obj, MemoryStream stm) at System.AppDomain.Serialize(Object o) at System.AppDomain.MarshalObject(Object o) at System.Threading.CompressedStack.GetDomainCompressedStack(SafeCompressedStackHandle compressedStack, Int32 index) at System.Security.PermissionListSet.CreateCompressedState(CompressedStack cs, CompressedStack innerCS) at System.Threading.CompressedStack.CompleteConstruction(CompressedStack innerCS) at System.Threading.CompressedStack.GetCompressedStack(StackCrawlMark& stackMark) at System.Security.SecurityContext.Capture(ExecutionContext currThreadEC, StackCrawlMark& stackMark) at System.Threading.ExecutionContext.Capture(StackCrawlMark& stackMark) at System.Threading.ExecutionContext.Capture() at System.Windows.Threading.Dispatcher.BeginInvokeImpl(DispatcherPriority priority, Delegate method, Object args, Boolean isSingleParameter) at System.Windows.Threading.Dispatcher.BeginInvoke(DispatcherPriority priority, Delegate method, Object arg) at System.Windows.Input.CommandManager.RaiseRequerySuggested() at System.Windows.Input.CommandManager.InvalidateRequerySuggested() at Microsoft.Windows.Design.Interaction.Tool.TaskCollection.InsertItem(Int32 index, Task item) at System.Collections.ObjectModel.Collection`1.Add(T item) at Microsoft.Windows.Design.Interaction.SelectionTool..ctor() at MS.Internal.Providers.VSActiveToolProvider.SelectionToolFactory.TryCreateTool[T](T& tool) at MS.Internal.Host.ToolSubsystem.ActivateTool(ToolFactory toolFactory) at MS.Internal.Host.ToolSubsystem..ctor(EditingContext editingContext, DesignerContext designerContext) at MS.Internal.Host.Designer.Load() at MS.Internal.Designer.VSDesigner.Load() at MS.Internal.Designer.VSIsolatedDesigner.VSIsolatedView.Load() at MS.Internal.Designer.VSIsolatedDesigner.VSIsolatedDesignerFactory.Load(IsolatedView view) at MS.Internal.Host.Isolation.IsolatedDesigner.BootstrapProxy.LoadDesigner(IsolatedDesignerFactory factory, IsolatedView view) at MS.Internal.Host.Isolation.IsolatedDesigner.BootstrapProxy.LoadDesigner(IsolatedDesignerFactory factory, IsolatedView view) at MS.Internal.Host.Isolation.IsolatedDesigner.Load() at MS.Internal.Designer.DesignerPane.LoadDesignerView()

XAML :

<Grid Name="pngrid_Base" Height="auto" Width="auto" Background="Beige">
    <Grid.ColumnDefinitions>
        <ColumnDefinition Width="auto" MinWidth="221"></ColumnDefinition>
        <ColumnDefinition Width="auto" MinWidth="1" MaxWidth="1"></ColumnDefinition>
        <ColumnDefinition Width="auto"></ColumnDefinition>
    </Grid.ColumnDefinitions>
        <Grid Name="pngrid_BaseForAll" Grid.Column="0" Width="auto" HorizontalAlignment="Left" Background="#FFD8E4F8">
     <Grid.RowDefinitions>
        <RowDefinition Height="30*"/>
        <RowDefinition Height="164*" />
        <RowDefinition Height="35*" />
        <RowDefinition Height="164*" />
        <RowDefinition Height="40*" />
    </Grid.RowDefinitions>
        <ListView  Name="lstview_Unack" Grid.Row="1" Margin="2,0,0,0" SelectionMode="Extended"  LostFocus="lstview_Unack_LostFocus" 
                                                                                                MouseRightButtonDown="lstview_Unack_MouseRightButtonDown">

            <ListView.ItemContainerStyle>
                <Style TargetType="ListViewItem">
                    <Setter Property="IsSelected" Value="{Binding Path=IsSelected, Mode=TwoWay}" />
                </Style>
            </ListView.ItemContainerStyle>
        </ListView>
        <Button Grid.Row="2" HorizontalAlignment="Left" Margin="24,14,0,5" Name="btnFreeze">Freeze</Button>
            <Button Grid.Row="2" HorizontalAlignment="Left" Margin="12,7,0,5" Name="btnAcknowledge" Width="96">Acknowledge</Button>
        <ListView  Name = "lstview_Ack" Grid.Row="3" Margin="2,1,0,0" LostFocus="lstview_Ack_LostFocus" SelectionMode="Extended" MouseRightButtonDown="lstview_Ack_MouseRightButtonDown">
            <ListView.ItemContainerStyle>
                <Style TargetType="ListViewItem">
                    <Setter Property="IsSelected" Value="{Binding Path=IsSelected, Mode=TwoWay}" />                            
                </Style>
            </ListView.ItemContainerStyle>
        </ListView>


        <Button Grid.Row="4" HorizontalAlignment="Left" Margin="16,12,0,7" Name="Clear" Width="78">Clear</Button>
    <TextBox Margin="110,6,32,5" Name="FilterText" TextChanged="FilterText_TextChanged" />
    <ComboBox HorizontalAlignment="Left" Margin="14,5,0,4" Name="comboColumnList" Width="94" />
</Grid>
    <GridSplitter Grid.Column="1" Name="gridSplitter1" Width="2" HorizontalContentAlignment="Center" VerticalContentAlignment="Stretch" HorizontalAlignment="Left" Background="Azure" />
    <Grid Name="pnGridForTreeView" Grid.Column="2" Width="200" Grid.ColumnSpan="2">
        <my:TrinityDeviceTree  x:Name ="m_objDeviceTree" Height="auto" Width="auto">

        </my:TrinityDeviceTree>
    </Grid>

</Grid>

解决方案

I've tested your code inside VS2008 with .NET 3.5 SP1 and if i remove declaration for TrinityDeviceTree it works fine with the designer. Maybe you should chek upon that UserControl and look there for errors. Also try to make a clean of your project and a rebuild, sometimes it works for visual designer's issues.

这篇关于在Visual Studio 2008中尝试编辑UI时,WPF设计器异常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆