Using Codebase to load assembly
Asked Answered
K

1

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>
Keto answered 18/12, 2011 at 17:11 Comment(0)
D
8

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

(from MSDN)

Darr answered 18/12, 2011 at 19:26 Comment(4)
I've made the path relative (using ../../...) and the same error message comes up.Keto
When you move the assembly into a child directory of your app instead of a parent directory, does it make a difference?Darr
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.Keto
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!Keto

© 2022 - 2024 — McMap. All rights reserved.