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

2
  • What is the relationship between the path of the main exe and the assembly (is it in a sub folder)? Commented Apr 15, 2009 at 8:30
  • Yes. It is located in subdirectory. Commented Apr 15, 2009 at 17:04

2 Answers 2

0

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

Sign up to request clarification or add additional context in comments.

3 Comments

AssemblyPrivate is just a static void main with Console.WriteLine so - Yes, I am sure.
Have you tried using the full path as an argument to the ExecuteAssembly method? In the standard Windows form, not as URL?
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
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

2 Comments

Q: "The AssemblyPrivate.exe does not have a public key", that's the problem.
If there is no public key, just leave out the whole publicKeyToken element. Worked for me.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.