在添加GalaSoft.MvvmLight(运行时版本v2.0.50727,版本0.0.0.0)和GalaSoft.MvvmLight.Extras(运行时v2.0.50727,版本0.0.0.0)dll后,我无法在设计时查看设计器。我在设计时遇到了这个例外。
System.IO.FileLoadException无法 加载文件或程序集 'GalaSoft.MvvmLight,版本= 0.0.0.0, Culture = neutral,PublicKeyToken = null' 或其中一个依赖项。手术 不受支持。 (例外 HRESULT:0x80131515)at System.Reflection.RuntimeAssembly n载入(的AssemblyName fileName,String codeBase,Evidence assemblySecurity,RuntimeAssembly locationHint,StackCrawlMark& stackMark,布尔 throwOnFileNotFound,布尔值 forIntrospection,布尔值 suppressSecurityChecks)at System.Reflection.RuntimeAssembly.nLoad(的AssemblyName fileName,String codeBase,Evidence assemblySecurity,RuntimeAssembly locationHint,StackCrawlMark& stackMark,布尔 throwOnFileNotFound,布尔值 forIntrospection,布尔值 suppressSecurityChecks)at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(的AssemblyName assemblyRef,证据 assemblySecurity,StackCrawlMark& stackMark,布局forIntrospection, 布尔值suppressSecurityChecks)at System.Reflection.Assembly.Load(的AssemblyName assemblyRef)at MS.Internal.Package.VSIsolationProviderService.RemoteReferenceProxy.VsReflectionResolver.GetRuntimeAssembly(大会 reflectionAssembly) Microsoft.Windows.Design.Metadata.ReflectionMetadataContext.CachingReflectionResolver.GetRuntimeAssembly(大会 reflectionAssembly) Microsoft.Windows.Design.Metadata.ReflectionMetadataContext.Microsoft.Windows.Design.Metadata.IReflectionResolver.GetRuntimeAssembly(大会 reflectionAssembly) MS.Internal.Metadata.ClrAssembly.GetRuntimeMetadata(对象 reflectionMetadata)at Microsoft.Windows.Design.Metadata.AttributeTableContainer.d _c.MoveNext() 在 Microsoft.Windows.Design.Metadata.AttributeTableContainer.GetAttributes(大会 assembly,Type attributeType,Func`2 reflectionMapper)at MS.Internal.Metadata.ClrAssembly.GetAttributes(ITypeMetadata attributeType)at MS.Internal.Design.Metadata.Xaml.XamlAssembly.get_XmlNamespaceCompatibilityMappings() 在 Microsoft.Windows.Design.Metadata.Xaml.XamlExtensionImplementations.GetXmlNamespaceCompatibilityMappings(IAssemblyMetadata sourceAssembly)at Microsoft.Windows.Design.Metadata.Xaml.XamlExtensions.GetXmlNamespaceCompatibilityMappings(IAssemblyMetadata 来源) MS.Internal.Design.Metadata.ReflectionProjectNode.BuildSubsumption() 在 MS.Internal.Design.Metadata.ReflectionProjectNode.SubsumingNamespace(标识符 标识符) MS.Internal.Design.Markup.XmlElement.BuildScope(PrefixScope parentScope,IParseContext context)at MS.Internal.Design.Markup.XmlElement.ConvertToXaml(XamlElement parent,PrefixScope parentScope, IParseContext上下文, IMarkupSourceProvider提供商) MS.Internal.Design.DocumentModel.DocumentTrees.Markup.XamlSourceDocument.FullParse(布尔 convertToXamlWithErrors)at MS.Internal.Design.DocumentModel.DocumentTrees.Markup.XamlSourceDocument.get_RootItem() 在 Microsoft.Windows.Design.DocumentModel.Trees.ModifiableDocumentTree.get_ModifiableRootItem() 在 Microsoft.Windows.Design.DocumentModel.MarkupDocumentManagerBase.get_LoadState() 在 MS.Internal.Host.PersistenceSubsystem.Load() 在MS.Internal.Host.Designer.Load()处 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()
System.NotSupportedException An 尝试加载程序集 从一个网络位置 导致组装 沙盒在以前的版本中 .NET Framework。这个版本的 .NET Framework不启用CAS 默认情况下,策略,所以此负载可能是 危险的。如果没有这个负载 打算组装沙箱, 请启用 loadFromRemoteSources切换。看到 http://go.microsoft.com/fwlink/?LinkId=155569 了解更多信息。
我正在使用.Net framework 4.0,WPF和c#。
这是我的代码
<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>
但是,所有功能都运行良好。请告诉我如何解决这个设计师问题。
答案 0 :(得分:0)
事件触发功能发生错误。设计时间不可用的原因。使用此代码检查数据网格中的一些错误
<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>