gpt4 book ai didi

mvvm - 在设计时无法查看WPF设计器

转载 作者:行者123 更新时间:2023-12-03 10:50:24 25 4
gpt4 key购买 nike

添加GalaSoft.MvvmLight(运行时版本v2.0.50727,版本0.0.0.0)和GalaSoft.MvvmLight.Extras(运行时v2.0.50727,版本0.0.0.0)dll之后,在设计时我无法查看设计器。在设计时我遇到了这个异常。

System.IO.FileLoadException Could not load file or assembly 'GalaSoft.MvvmLight, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515) at System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) at System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection, Boolean suppressSecurityChecks) at System.Reflection.Assembly.Load(AssemblyName assemblyRef) at MS.Internal.Package.VSIsolationProviderService.RemoteReferenceProxy.VsReflectionResolver.GetRuntimeAssembly(Assembly reflectionAssembly) at Microsoft.Windows.Design.Metadata.ReflectionMetadataContext.CachingReflectionResolver.GetRuntimeAssembly(Assembly reflectionAssembly) at Microsoft.Windows.Design.Metadata.ReflectionMetadataContext.Microsoft.Windows.Design.Metadata.IReflectionResolver.GetRuntimeAssembly(Assembly reflectionAssembly) at MS.Internal.Metadata.ClrAssembly.GetRuntimeMetadata(Object reflectionMetadata) at Microsoft.Windows.Design.Metadata.AttributeTableContainer.d_c.MoveNext() at Microsoft.Windows.Design.Metadata.AttributeTableContainer.GetAttributes(Assembly assembly, Type attributeType, Func`2 reflectionMapper) at MS.Internal.Metadata.ClrAssembly.GetAttributes(ITypeMetadata attributeType) at MS.Internal.Design.Metadata.Xaml.XamlAssembly.get_XmlNamespaceCompatibilityMappings() at Microsoft.Windows.Design.Metadata.Xaml.XamlExtensionImplementations.GetXmlNamespaceCompatibilityMappings(IAssemblyMetadata sourceAssembly) at Microsoft.Windows.Design.Metadata.Xaml.XamlExtensions.GetXmlNamespaceCompatibilityMappings(IAssemblyMetadata source) at MS.Internal.Design.Metadata.ReflectionProjectNode.BuildSubsumption() at MS.Internal.Design.Metadata.ReflectionProjectNode.SubsumingNamespace(Identifier identifier) at MS.Internal.Design.Markup.XmlElement.BuildScope(PrefixScope parentScope, IParseContext context) at MS.Internal.Design.Markup.XmlElement.ConvertToXaml(XamlElement parent, PrefixScope parentScope, IParseContext context, IMarkupSourceProvider provider) at MS.Internal.Design.DocumentModel.DocumentTrees.Markup.XamlSourceDocument.FullParse(Boolean convertToXamlWithErrors) at MS.Internal.Design.DocumentModel.DocumentTrees.Markup.XamlSourceDocument.get_RootItem() at Microsoft.Windows.Design.DocumentModel.Trees.ModifiableDocumentTree.get_ModifiableRootItem() at Microsoft.Windows.Design.DocumentModel.MarkupDocumentManagerBase.get_LoadState() at MS.Internal.Host.PersistenceSubsystem.Load() 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()

System.NotSupportedException An attempt was made to load an assembly from a network location which would have caused the assembly to be sandboxed in previous versions of the .NET Framework. This release of the .NET Framework does not enable CAS policy by default, so this load may be dangerous. If this load is not intended to sandbox the assembly, please enable the loadFromRemoteSources switch. See http://go.microsoft.com/fwlink/?LinkId=155569 for more information.



我正在使用C#的.Net Framework 4.0 WPF。

这是我的代码
<Window x:Class="TreeviewApp.MainWindow" 
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
xmlns:cmd="clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight.Extras"
xmlns:dataGrid="http://schemas.microsoft.com/wpf/2008/toolkit"
Title="MainWindow" Height="350" Width="525">
<Window.Resources>
<DataTemplate x:Key="DetailTemplate">
<TextBlock Text="{Binding Swift_File_Name}"/>
</DataTemplate>
<HierarchicalDataTemplate x:Key="MasterTemplate"
ItemsSource="{ Binding SwiftCol,Mode=TwoWay}"
ItemTemplate="{StaticResource DetailTemplate}">
<HierarchicalDataTemplate.ItemContainerStyle>
<Style TargetType="TreeViewItem">
<Setter Property="IsSelected" Value="{Binding IsExpanded,Mode=TwoWay}"/>
</Style>
</HierarchicalDataTemplate.ItemContainerStyle>
<TextBlock Text="{Binding CITA_Info_Id}"/>
</HierarchicalDataTemplate>
<!--<Style TargetType="TreeViewItem">
<Setter Property="IsExpanded" Value="True" />
</Style>-->
 
 
 
 
<!--<Style x:Key="myStyle" TargetType="TreeViewItem">
<Setter Property="IsExpanded" Value="True" />
</Style>-->
</Window.Resources>
<Grid>
<Button Content="Button" Height="23" HorizontalAlignment="Left" Margin="428,0,0,0" Name="button1" Command="{Binding btnClick}" VerticalAlignment="Top" Width="75" />
<TreeView Height="288" HorizontalAlignment="Left" Margin="18,23,0,0" VerticalAlignment="Top" Width="89"
x:Name="tvCita" ItemsSource="{Binding CitaCol,Mode=TwoWay}" ItemTemplate="{StaticResource MasterTemplate}">
<TreeView.ItemContainerStyle>
<Style TargetType="{x:Type TreeViewItem}">
<Setter Property="IsExpanded" Value="True"/>
</Style>
</TreeView.ItemContainerStyle>
<i:Interaction.Triggers>
<i:EventTrigger EventName="SelectedItemChanged">
<cmd:EventToCommand Command="{Binding TreeviewItemClick}" CommandParameter="{Binding SelectedItem, ElementName= tvCita, Mode=OneWay}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</TreeView>
<dataGrid:DataGrid Name="dgSwift" Margin="105,24,0,0" ItemsSource="{Binding Path = SwiftCol}" AutoGenerateColumns="False" CanUserAddRows="False">
<dataGrid:DataGrid.Columns>
<dataGrid:DataGridTextColumn Header="0000" Binding="{Binding Path = Line_0000_count}"></dataGrid:DataGridTextColumn>
<dataGrid:DataGridTextColumn Header="1000" Binding="{Binding Path = Line_1000_count}"></dataGrid:DataGridTextColumn>
<dataGrid:DataGridTextColumn Header="1100" Binding="{Binding Path = Line_1100_Count}"></dataGrid:DataGridTextColumn>
<dataGrid:DataGridTextColumn Header="1110" Binding="{Binding Path = Line_1110_count}"></dataGrid:DataGridTextColumn>
</dataGrid:DataGrid.Columns>
</dataGrid:DataGrid>
</Grid>
</
Window>

但是,所有功能都可以正常工作。请告诉我如何解决此设计师问题。

最佳答案

错误发生在事件触发功能中。设计在设计时间内无法使用的原因。与此代码在datagrid检查中也有一些错误

<Window x:Class="TreeviewApp.MainWindow" 
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
xmlns:cmd="clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight.Extras"
xmlns:dataGrid="http://schemas.microsoft.com/wpf/2008/toolkit"
Title="MainWindow" Height="350" Width="525">
<Window.Resources>
<DataTemplate x:Key="DetailTemplate">
<TextBlock Text="{Binding Swift_File_Name}"/>
</DataTemplate>
<HierarchicalDataTemplate x:Key="MasterTemplate"
ItemsSource="{ Binding SwiftCol,Mode=TwoWay}"
ItemTemplate="{StaticResource DetailTemplate}">
<HierarchicalDataTemplate.ItemContainerStyle>
<Style TargetType="TreeViewItem">
<Setter Property="IsSelected" Value="{Binding IsExpanded,Mode=TwoWay}"/>
</Style>
</HierarchicalDataTemplate.ItemContainerStyle>
<TextBlock Text="{Binding CITA_Info_Id}">
</TextBlock>
</HierarchicalDataTemplate>
</Window.Resources>
<Grid>
<Button Content="Button" Height="23" HorizontalAlignment="Left" Margin="428,0,0,0" Name="button1" Command="{Binding btnClick}" VerticalAlignment="Top" Width="75" />
<TreeView Height="288" HorizontalAlignment="Left" Margin="18,23,0,0" VerticalAlignment="Top" Width="89" x:Name="tvCita" ItemsSource="{Binding CitaCol,Mode=TwoWay}" ItemTemplate="{StaticResource MasterTemplate}">
<TreeView.ItemContainerStyle>
<Style TargetType="{x:Type TreeViewItem}">
<Setter Property="IsExpanded" Value="True"/>
</Style>
</TreeView.ItemContainerStyle>
<!--<i:Interaction.Triggers>
--><!--<i:EventTrigger EventName="SelectedItemChanged">
<cmd:EventToCommand Command="{Binding TreeviewItemClick}" CommandParameter="{Binding SelectedItem, ElementName= tvCita, Mode=OneWay}"/>
</i:EventTrigger>--><!--
</i:Interaction.Triggers>-->
</TreeView>
<DataGrid Name="dgSwift" Margin="105,24,0,0" ItemsSource="{Binding Path = SwiftCol}" AutoGenerateColumns="False" CanUserAddRows="False">
<DataGrid.Columns >
<DataGridTextColumn Header="0000" Binding="{Binding Path = Line_0000_count}"></DataGridTextColumn>
<DataGridTextColumn Header="1000" Binding="{Binding Path = Line_1000_count}"></DataGridTextColumn>
<DataGridTextColumn Header="1100" Binding="{Binding Path = Line_1100_Count}"></DataGridTextColumn>
<DataGridTextColumn Header="1110" Binding="{Binding Path = Line_1110_count}"></DataGridTextColumn>
</DataGrid.Columns>
</DataGrid>
</Grid>
</Window>

关于mvvm - 在设计时无法查看WPF设计器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5606016/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com