2011-04-09 78 views
1

添加GalaSoft.MvvmLight(运行时版本v2.0.50727,版本0.0.0.0)和GalaSoft.MvvmLight.Extras(运行时v2.0.50727,版本0.0.0.0)dll。我在设计时得到这个例外。无法在设计时查看WPF设计器

System.IO.FileLoadException未能进行 加载文件或组件 'GalaSoft.MvvmLight,版本= 0.0.0.0, 文化=中性公钥=空' 或它的一个依赖。操作 不受支持。 (例外从 HRESULT:0x80131515)在 System.Reflection.RuntimeAssembly。 n载入(的AssemblyName 文件名,字符串的代码库,证据 assemblySecurity,RuntimeAssembly locationHint,StackCrawlMark & stackMark,布尔 throwOnFileNotFound,布尔 forIntrospection,布尔 suppressSecurityChecks)在 System.Reflection.RuntimeAssembly.nLoad(的AssemblyName 文件名,字符串的代码库,证据 assemblySecurity,RuntimeAssembly locationHint,StackCrawlMark & stackMark,布尔 throwOnFileNotFound,布尔 forIntrospection,布尔 个suppressSecurityChecks)在 System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(的AssemblyName assemblyRef,证据 assemblySecurity,StackCrawlMark & stackMark,布尔forIntrospection, 布尔suppressSecurityChecks)在 System.Reflection.Assembly.Load(的AssemblyName assemblyRef)在 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)在 Microsoft.Windows.Design。 Metadata.AttributeTableContainer.d _c.MoveNext() 处 MS.Internal.Metadata.ClrAssembly.GetAttributes Microsoft.Windows.Design.Metadata.AttributeTableContainer.GetAttributes(大会 组件,类型属性类型,Func`2 reflectionMapper) (ITypeMetadata attributeType)at MS.Internal.Design.Metadata.Xaml.XamlAssembly.get_XmlNamespaceCompatibility映射() 处 MS.Internal Microsoft.Windows.Design.Metadata.Xaml.XamlExtensionImplementations.GetXmlNamespaceCompatibilityMappings(IAssemblyMetadata sourceAssembly)在 Microsoft.Windows.Design.Metadata.Xaml.XamlExtensions.GetXmlNamespaceCompatibilityMappings(IAssemblyMetadata 源)。 Design.Metadata.ReflectionProjectNode.BuildSubsumption() 在 MS.Internal.Design.Metadata.ReflectionProjectNode.SubsumingNamespace(识别符 标识符)在 MS.Internal.Design.Markup.XmlElement.BuildScope(PrefixScope parentScope,IParseContext上下文)在 MS.Internal.Design.Markup.XmlElement。ConvertToXaml(XamlElement 父,PrefixScope parentScope, IParseContext上下文, IMarkupSourceProvider提供商)在 MS.Internal.Design.DocumentModel.DocumentTrees.Markup.XamlSourceDocument.FullParse(布尔 convertToXamlWithErrors)在 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() at MS.Internal.Host.Designer.Loa d()在 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(在 MS IsolatedDesignerFactory 工厂,IsolatedView视图)在 MS.Internal.Host.Isolation.IsolatedDesigner.BootstrapProxy.LoadDesigner(IsolatedDesignerFactory 工厂,IsolatedView视图) .Internal.Host.Isolation.IsolatedDesigner.Load() at MS.Internal.Designer.DesignerPane.LoadDesignerView()

System.NotSupportedException一种 试图从这将 造成的组件是 在 .NET框架的先前版本沙箱的网络位置加载程序集 。此版本的.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

您是否尝试了错误链接中的建议? http://go.microsoft.com/fwlink/?LinkId=155569 – 2011-04-09 15:58:43

+0

您需要使用[Fusion日志查看器]进行调试(http://msdn.microsoft.com/zh-cn/library/e74a18c4 (v = VS.100).aspx)只要确保以管理员身份运行它,打开日志并在尝试调试之前重新启动。您将看到CLR正在查找程序集的位置以及哪个版本,并从那里确定它未找到的原因(如果您已安装它)。 – Will 2011-04-11 13:39:51

+0

你见过http://stackoverflow.com/questions/2714417/mvvm-light-toolkit-throws-an-system-io-fileloadexception – 2012-03-19 10:56:22

回答

0

错误发生在事件触发器函数中。原因设计在设计时不可用。 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> 
+0

这不是一个答案.. – pix 2017-09-12 13:23:08