开发者

Unable to view the WPF designer at design time

开发者 https://www.devze.com 2023-02-23 00:33 出处:网络
I’m unable view the designer at designtime after adding GalaSoft.MvvmLight(Runtime version v2.0.50727, version 0.0.0.0) and GalaSoft.MvvmLight.Extras(Runtime v2.0.50727, version 0.0.0.0) dlls. I am g

I’m unable view the designer at designtime after adding GalaSoft.MvvmLight(Runtime version v2.0.50727, version 0.0.0.0) and GalaSoft.MvvmLight.Extras(Runtime v2.0.50727, version 0.0.0.0) dlls. I am getting this exception at design time.

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.

I am using .Net framework 4.0 ,WPF with c#.

Here my code

<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开发者_JAVA技巧" 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>

But, all the functionality is working fine. Please tell me how to fix this designer issue.


the error occur in event trigger function . the reason design is not available in the design time. also some error in datagrid check with this code

<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

精彩评论

暂无评论...
验证码 换一张
取 消