Search code examples
c#.netdll.net-assembly

Can I change the already referenced DLL's path?


I am searching for a way to change the DLL's path without having to use Assembly.LoadFrom or .Load.

I cannot change the code, and it already references DLL's like Namespace.Class.Method. Is there a way to change the path of that DLL and tell .net to look for it using a new path? The new path is known, so I just need a way to point it there.

Any help would be appreciated.

Thank you in advance.


Solution

  • If the path is already hard-coded, I can't see how you can change that without editing the code, but perhaps there is another alternative:

    If you have the correct dll-file (correct name and version number as referenced by .net) in the Global Assembly Cache (the "GAC"), then there is a chance .NET might load it from there.

    I'm saying it might do so, because I'm not sure about how this works if you're explicitly loading a dll directly from code. If the assembly is simply referenced by name / namespace in the normal way though, it should search for the library in the gac first.

    May be worth a shot anyway. You'll find your GAC at: %windir%\Microsoft.NET\assembly