6

Based on this question, I tried using <codebase> to locate an external assembly. Now, when I run the program, I get an error message saying that the private assembly was located outside the appbase. How can I fix this issue? One suggestion I saw said to sign the assembly. I did this, but then my program couldn't find the assembly. When I unsigned it, I get the outside the appbase error. How do I load an assembly that's located elsewhere using <codebase> and not installing to the GAC? (Probing didn't work either and it seems that it still has to be present within the application folder) My config file:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>

        <assemblyIdentity name="NGameHost"

                          culture="neutral" />
        <codeBase version="1.0.0.0" 
                  href="C:/Program Files/NetworkGame3/api/NGameHost.exe"/>
      </dependentAssembly>
    </assemblyBinding>
  </runtime>

</configuration>
Community
  • 1
  • 1
XSL
  • 2,965
  • 7
  • 38
  • 61

1 Answers1

8

If the assembly is a private assembly, the codebase setting must be a path relative to the application's directory.

(from MSDN)

sq33G
  • 3,320
  • 1
  • 23
  • 38
  • I've made the path relative (using ../../...) and the same error message comes up. – XSL Dec 18 '11 at 19:30
  • When you move the assembly into a child directory of your app instead of a parent directory, does it make a difference? – sq33G Dec 18 '11 at 19:33
  • The problem is, the dll is located in that specific directory because a lot of other dependencies are there as well, so I can't move it to my child directory. However if I create a new project in that directory and call the DLL, it claims it can't load another dependecy (which the original DLL can load). Maybe that's the DLL that's causing the problem. – XSL Dec 18 '11 at 19:44
  • Thanks sq33G, your comment put me on the right path. It turned out that the problem was with one of the dependency DLLs, not the one I was calling. I had to switch my framework profile to 2.0 (which is what the dependency uses) and it now works! – XSL Dec 18 '11 at 19:46