2009-09-19 28 views
2

以下是我的目錄結構ASP.NET集探測問題

E:\測試\探測

目錄探測containts可執行[Probing.exe]其中加載DLL文件(Probe.dll) 。

的代碼是:

namespace Probing 

    { 
    class Program 

    { 
     static void Main(string[] args) 

     { 

       Assembly asm = Assembly.Load("Probe.dll"); 

       if (asm != null) 

       { 

        Console.WriteLine("Assembly Probe is loaded"); 

       } 

       else 

       { 
        Console.WriteLine("Assembly Probe is not loaded"); 
       } 

     } 
    } 
} 

DLL文件是(Probe.dl)駐留在子目錄(例如:\測試\探測\ CustomLibraries \ Probe.dll)。

我提供了Probing.exe.config文件,甚至App.config來定位程序集。

配置文件包含以下代碼:

<configuration> 

<runtime> 

<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> 

<probing privatePath="CustomLibraries"/> 

</assemblyBinding> 

</runtime> 

</configuration> 

我收到FileNotFound異常,直到我把DLL的bin目錄內。

我需要你們的幫助(我使用Visual Studio 2008)

回答

4

的第一件事,試圖調試這是setup Fusion logging做 - 這樣你會看到檢查的目錄。

探測只適用於您的應用程序目錄下的子目錄,所以如果像您說的那樣,您的應用程序位於... \ bin並且您的庫位於... \ lib中,它將無法工作 - 它們需要在... \ bin \ lib中。您需要使用codebase代替