C# 在app.config中引用程序集

C# 在app.config中引用程序集,c#,wpf,xaml,app-config,gac,C#,Wpf,Xaml,App Config,Gac,我知道以前有人问过这个问题,但不是在这种情况下 我有一个WPF应用程序(第三方),可以添加一个XAML ResourceDictionary,因此我创建了一个类库,其中包含一个实现ICommand接口的类 并在Execute方法中调用WebService 现在我想将此命令附加到应用程序中的控件 这是我的资源字典: <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentat

我知道以前有人问过这个问题,但不是在这种情况下

我有一个WPF应用程序(第三方),可以添加一个XAML ResourceDictionary,因此我创建了一个类库,其中包含一个实现ICommand接口的类 并在Execute方法中调用WebService

现在我想将此命令附加到应用程序中的控件

这是我的资源字典:

        <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                        xmlns:iet="clr-namespace:iETSolutions.Enterprise.WorkCenter.Controls;assembly=iETSolutions.Enterprise.WorkCenter.Controls"
                        xmlns:custom="clr-namespace:Custom.Test;assembly=Custom.Test">
                 <Style TargetType="{x:Type Button}">
                    <Style.Triggers>
                        <DataTrigger Binding="{Binding RelativeSource={RelativeSource Self}, Path=Name}" Value="SearchButton">
                            <Setter Property="Template">
                                <Setter.Value>
                                    <ControlTemplate TargetType="{x:Type Button}">
                                        <Grid>
                                            <Button Command="{StaticResource cmd}" CommandParameter="{Binding ElementName=SearchTextBox, Path=Text}">
                                                <Image Source="pack://application:,,,/iETSolutions.Enterprise.WorkCenter;component/Images/PNG/iET_search.png" />
                                            </Button>
                                        </Grid>
                                    </ControlTemplate>
                                </Setter.Value>
                            </Setter>
                        </DataTrigger>
                    </Style.Triggers>
                 </Style>
</ResourceDictionary>

因此,如果我将Custom.Test.dll添加到GAC中,但如果我尝试从app.config引用dll,CommandCall就会失败,这就像charm一样有效

以下是我在App.config中尝试引用程序集的内容:

<runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">    
      <dependentAssembly>
        <assemblyIdentity name="Custom.Test" publicKeyToken="314daa73fc3fb7cf" culture="neutral"/>
        <codeBase version="1.0.0.0" href="http://localhost/Custom/Custom.Test.dll" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>

有没有可能我可以让这个工作,而不需要把我的自定义DLL在GAC


对于应用程序的滚出,将引用放在App.config中要容易得多…

是否尝试将Custom.Test.DLL放在应用程序可执行文件所在的同一目录中?

否没有尝试…如果将其放在同一目录中,我如何引用App.config中的文件?甚至不必这样做在app.config中引用该文件,只需将其放在同一目录中即可!没想到这么简单^^^谢谢不用谢。WPF只是尝试加载程序集,如果您在代码中加载了assembly.load(name),则也是如此。NET汇编加载程序称为“Fusion”。加载过程从应用程序目录开始,然后经过一系列其他地方,最后到达GAC。谷歌“.netfusion”。