1

次のクライアント アプリケーションとそれに対応するconfigファイルがあります。

namespace Chapter9
{
    class Program
    {
        static void Main(string[] args)
        {
            AppDomain.CurrentDomain.ExecuteAssembly("AssemblyPrivate.exe");
        }
    }
}

<configuration>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <codeBase href="file://C:\Users\djpiter\Documents\Visual Studio 2008\Projects\70536\AssemblyPrivate\bin\Debug\AssemblyPrivate.exe"/>
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
</configuration>

にはAssemblyPrivate.exe公開鍵がなく、GAC にもありません。私の知る限り、ランタイムはapp.configクライアント アプリ ディレクトリでアセンブリを探す前にファイルを解析する必要があります。

未処理の例外 (読みやすいようにラップされています) は次のとおりです。

Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly
'file:///C:\Users\djpiter\Documents\Visual Studio 2008\Projects\70536\Chapter9\bin\Debug\AssemblyPrivate.exe'
or one of its dependencies. The system cannot find the file specified.

なぜ機能しないのですか?(静的ではなく) 動的バインディングを使用する必要があります。

敬具、PK

4

2 に答える 2

0

あなたはおそらく今までにこの問題を自分で解決したので、参考のために:

「assemblyIdentity」要素が欠落していると思います。codeBase要素に追加して指定すると、機能するはずです。

 <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="office"
                  publicKeyToken="71e9bce111e9429c" />
        <codeBase href="Microsoft.Office.Interop.v11.dll" version="11.0.0.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>

http://msdn.microsoft.com/en-us/library/b0yt6ck0%28v=VS.100%29.aspxを参照してください

于 2010-05-17T07:04:01.523 に答える
0

その「またはその依存関係の1つ」を見落とさないでください。AssemblyPrivate.exeのすべての依存関係が利用可能であると確信していますか?

于 2009-04-14T17:17:23.583 に答える