c# - 在 app.config 中引用程序集

标签 c# wpf xaml app-config gac

我知道这个问题以前曾被问过,但不是在这种情况下提出的!

我有一个 WPF 应用程序(第三方),它使我可以添加 XAML ResourceDictionary,因此我创建了一个带有实现 ICommand 接口(interface)的类的 ClassLibrary 并在执行方法中调用 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 会失败...

这是我在 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 放在应用程序可执行文件所在的同一目录中?

关于c# - 在 app.config 中引用程序集,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17284343/

相关文章:

c# - 安全代码中的不安全标签

c# - 将远程图像保存到独立存储

WPF 主窗口控件绑定(bind)属性从另一个窗口更改

c# - WPF:如何自定义通用自定义窗口?

c# - WPF 将应用程序命令绑定(bind)到 ViewModel ICommand

xaml - 是否有 XAML 的 * 单元的 CSS 等价物?

java - 如何在 C#/Xamarin 中使用带有 Android 钥匙串(keychain)私钥的 X.509 证书?

c# - 如何在没有编译时常量的情况下设置可选参数

c# - 如何将在线程 X 中创建的 WPF 对象传递给线程 Y?

WPF ErrorTemplate 未聚焦时可见?