1

I have a running appliation which load an Assembly in runtime. I have a folder, which full of .dll files. Whenever a caller make a request, my application will look into a selected dll and load it. Here is snippet of my codes.

if (File.Exists(Path.Combine(assemblySavePath, proxy.AssemblyFileName)))
{
    Assembly = Assembly.LoadFile(Path.Combine(assemblySavePath, proxy.AssemblyFileName));  
    // after this just use it normally
}

Basically whenever a request, I will load it. So my question is, performance wise, is this the correct way? Because I was wondering whether there's a way I could look into memory/GAC/AppDomain first, check whether it existed, without needing me to LoadFile() everytime there's a request.

EOF
  • 6,273
  • 2
  • 26
  • 50
dausdashsan
  • 241
  • 1
  • 6
  • 16
  • To save memory you can use another `AppDomain` to [load/unload](http://stackoverflow.com/q/6578170/1997232) assemblies into. Performance wise you should load them once into current `AppDomain` as @nvoigt answer suggesting. – Sinatr Oct 30 '14 at 13:31

1 Answers1

0

You should at least have a list which assemblies you already loaded and check that. As you cannot unload an assembly from your AppDomain, you don't have to try to load it again.

nvoigt
  • 75,013
  • 26
  • 93
  • 142
  • Yes, that the way I'm looking for actually. How to check on runtime? And how to retrieve the Assembly instance again? – dausdashsan Oct 30 '14 at 12:37
  • You could save the path and assembly to a dictionary. But why do you need the assembly instance later on? – nvoigt Oct 30 '14 at 12:42