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

不要忽视“或其依赖项之一”。您确定所有 AssemblyPrivate.exe 的依赖项都可用吗?

于 2009-04-14T17:17:23.583 回答
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 回答