WPF设计器异常,试图在Visual studio 2008中编辑UI

时间:2022-07-30 01:52:40

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

我在我的机器上安装了。net 3.5 SP1的VS2008,我写了一个简单的应用程序,有两个listview和databinding,我的应用程序编译良好,我可以运行它,但是当我尝试打开designer来编辑控件时,我得到了以下错误。我不明白为什么会这样。任何想法…请参见此错误消息下面的xaml。

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()

“MS.Internal.Permissions类型。UserInitiatedNavigationPermission' in Assembly 'PresentationFramework, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'没有被标记为serializable。在System.Runtime.Serialization.FormatterServices。在System.Runtime.Serialization.FormatterServices InternalGetSerializableMembers(RuntimeType类型)。在system . runtime . serializ.formatters.binaro . writeobjectinfo. initmemberinfo()位于system . runtime. serializ.orgters.binary.format . system.com。InitSerialize(Object obj, ISurrogateSelector surrogateSelector, StreamingContext, SerObjectInfoInit, IFormatterConverter, ObjectWriter ObjectWriter ObjectWriter ObjectWriter)在system . runtime. serializ.co.jpter . binary.org . objectinfo。序列化(Object obj, ISurrogateSelector surrogateSelector, StreamingContext, serobjectinfoinitserobjectinfoinitserobjectinfoinit, IFormatterConverter, ObjectWriter ObjectWriter ObjectWriter)到system . runtime. serializ.ters.binary.format。写入(WriteObjectInfo objectInfo objectInfo、NameInfo memberNameInfo、NameInfo typeNameInfo)到system . runtime . serializ.formatters.binar . objectwriter。序列化(对象图,页眉[]inheader, __BinaryWriter serWriter, Boolean fCheck)在system . runtime . serializ.formatters.binar . binaryformatter。序列化(流serializationStream, Object graph, Header[], Boolean fCheck)在System.Runtime.Remoting.Channels.CrossAppDomainSerializer。SerializeObject(Object obj, MemoryStream stm)位于System.AppDomain。在System.AppDomain序列化(对象o)。在System.Threading.CompressedStack MarshalObject(对象o)。getdomcompressedstack (SafeCompressedStackHandle compressedStack, Int32 index)位于System.Security.PermissionListSet。创建压缩状态(压缩堆栈cs,压缩堆栈内部cs)在system . thread .CompressedStack。在System.Threading.CompressedStack CompleteConstruction(CompressedStack innerCS)。在System.Security.SecurityContext GetCompressedStack(StackCrawlMark& stackMark)。捕获(ExecutionContext threadec, stackcrawlmark和stackMark)在system . thread .ExecutionContext。捕获(stackcrawlmark&stackmark)在system . thread . executioncontext.capture()在system . windows . thread . dispatcher。BeginInvokeImpl(DispatcherPriority、Delegate方法、Object args、Boolean isSingleParameter)在system . windows . thread . dispatcher。在system . windows . windows . inputer . management . raiserequerysuggest()位于system . windows . windows . windows . inputer . commandmanager . invalidaterequerysuggest()位于microsoft.windows . windows . design . interaction . tools . taskcollection。在system . collection. objectmodel . collection . collection . 1中插入(Int32索引、任务项)。在Microsoft.Windows.Design.Interaction.SelectionTool. ctor()在ms . internal.provider . vsactivetoolprovider . selectiontoolfactory .TryCreateTool MS.Internal.Host.ToolSubsystem[T](T工具)。ActivateTool(ToolFactory ToolFactory)MS.Internal.Host.ToolSubsystem . .英语作文网-英语作文网-英语作文网-英语作文网-英语作文网-英语作文网-英语作文网-英语作文网-英语作文网-英语作文网-英语作文网-英语作文网-英语作文网-英语作文网-英语作文网-英语作文网在MS.Internal.Host.Isolation.IsolatedDesigner.BootstrapProxy负载(IsolatedView视图)。LoadDesigner(孤立的设计工厂,孤立的视图)在ms . internal.host.isolateddesigner.bootstrapproxy。LoadDesigner(孤立的设计工厂,孤立的视图)在ms . internal.host.isoles.net . isolateddesigner.load()在ms。

XAML :

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>

1 个解决方案

#1


1  

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.

我已经在VS2008中使用。net 3.5 SP1测试了您的代码,如果我删除了TrinityDeviceTree的声明,它对设计人员来说是可以工作的。也许你应该在UserControl上查找错误。还可以尝试清理项目和重新构建,有时它可以解决视觉设计人员的问题。

#1


1  

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.

我已经在VS2008中使用。net 3.5 SP1测试了您的代码,如果我删除了TrinityDeviceTree的声明,它对设计人员来说是可以工作的。也许你应该在UserControl上查找错误。还可以尝试清理项目和重新构建,有时它可以解决视觉设计人员的问题。