2011-11-30 72 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"/>