1

I have the following client application and its corresponding config file:

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>

The AssemblyPrivate.exe does not have a public key, nor is it located in the GAC. As far as I know, the runtime should parse the app.config file before looking for an assembly in the client app directory.

The unhandled exception (wrapped for readability) is:

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.

Why it is not working? I need to use dynamic binding (not static).

Wai Ha Lee
  • 8,598
  • 83
  • 57
  • 92
pkolodziej
  • 1,347
  • 3
  • 17
  • 24

2 Answers2

0

You probably solved this problem on your own by now, so just for reference:

I believe you are missing an "assemblyIdentity" element. If you specify it additionally to the codeBase element, it should work.

 <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>

See http://msdn.microsoft.com/en-us/library/b0yt6ck0%28v=VS.100%29.aspx

floele
  • 3,668
  • 4
  • 35
  • 51
0

Don't overlook that "or one of its dependencies". Are you sure all AssemblyPrivate.exe's dependencies are available?

Igor Brejc
  • 18,714
  • 13
  • 76
  • 95
  • AssemblyPrivate is just a static void main with Console.WriteLine so - Yes, I am sure. – pkolodziej Apr 14 '09 at 17:19
  • Have you tried using the full path as an argument to the ExecuteAssembly method? In the standard Windows form, not as URL? – Igor Brejc Apr 14 '09 at 17:22
  • I know, but if you want to find out where the problem lies, you have to do a little bit of experimenting... that's always the case with these kinds of things – Igor Brejc Apr 14 '09 at 17:27