2011-11-30 70 views
2

更新:我已经强烈建议我的DLL,但我的codeBase标记似乎没有任何效果。 Fusion不会将我的自定义目录显示为dll扫描目标之一。启动我的服务仍会引发FileNotFoundException。运行时引用外部DLL

我在我的项目根目录的子文件夹中有几个exe文件。我需要将一个DLL放入根目录,并启用所有这些exe引用它。到目前为止,我已经编辑了我的exe文件的app.config文件为这样:

<configuration> 
    <runtime> 
     <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> 
     <dependentAssembly> 
      <assemblyIdentity name="resources" 
          publicKeyToken="fe437a7f5a917214" 
          culture="neutral" /> 
      <codeBase version="1.0.0.0" 
        href="file:///c:/program files (x86)/root Directory/resources.dll"/> 
     </dependentAssembly> 
     </assemblyBinding> 
    </runtime> 
</configuration> 

我的exe具有通过与“复制本地”选项设置为false IDE中设置的参考。然而,当我尝试启动我的exe(这是一个Windows服务),它错误,并写入一个Wi​​ndows事件日志抛出System.IO.FileNotFoundException。

我错过了什么?

+1

你真的有一个叫做'根Directory'在'目录C:\ Program Files文件(x86)的\'?看起来很不寻常。 – Polynomial

+3

您是否尝试过使用Assembly.Load()加载它并使用相同的路径? – oberfreak

+0

我的exe目前正在尝试调用Load(),但服务无法启动,所以它永远不会发生。 – Julien

回答

0
href="file:///c:/program files (x86)/root Directory/resources.dll"/> 

需求是

href="file:///c:\program files (x86)\root Directory\resources.dll"/>