【问题标题】:Reference Assembly in app.configapp.config 中的引用程序集
【发布时间】:2013-06-21 11:35:57
【问题描述】:

我知道之前有人问过这个问题,但不是在这个上下文中!

我有一个 WPF 应用程序(第三方),它使我可以添加 XAML 资源字典,因此我创建了一个带有实现 ICommand 接口的类的 ClassLibrary 并在 Execute-Method 中调用 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 中引用会更容易...

【问题讨论】:

    标签: c# wpf xaml app-config gac


    【解决方案1】:

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

    【讨论】:

    • no 没试过……如果我把app.config中的文件放在同一个目录下,我该如何引用它?
    • 甚至不必引用 app.config 中的文件,只需将其放在同一个目录中即可!没想到这么简单^^谢谢
    • 不客气。 WPF 只是尝试加载程序集,如果您在代码中执行 Assembly.Load(name) 也是如此。 .NET 程序集加载器称为“Fusion”。加载过程从应用程序目录开始,然后经过许多其他地方并在 GAC 中结束。谷歌“.NET Fusion”。
    猜你喜欢
    • 2011-04-03
    • 2012-07-16
    • 2015-05-28
    • 1970-01-01
    • 2010-11-11
    • 1970-01-01
    • 2010-10-24
    • 2014-09-01
    • 1970-01-01
    相关资源
    最近更新 更多