2011-04-09 307 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