0

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.

Kjartan
  • 18,591
  • 15
  • 71
  • 96

1 Answers1

0

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

Kjartan
  • 18,591
  • 15
  • 71
  • 96
  • It is referenced like you said. What I have to do is make .NET search the directory I specify too. I hope it makes sense. – onur kılınç Jul 16 '18 at 07:54
  • In that case, I doubt it can be done without changing the source code. Too bad it's hard-coded - it would probably have been a better idea to specify it in a config file which could have been changed more easily... – Kjartan Jul 16 '18 at 07:58
  • How can I specify it in a config file? Sorry I am kind of a newbie. – onur kılınç Jul 16 '18 at 08:04
  • Again, you would have to change the source code; if you define some kind of config file (an `app.config`, for instance), you could read the path from there, and pass it to .Net (Assembly.LoadFrom) as a variable instead of having it hard coded; but if as you say, you can't change the code, then this does not help you, sorry! – Kjartan Jul 16 '18 at 09:28