Reputation: 11319
I am loading assemblies using Assembly.LoadFile(assemblyFilePath) in a loop and I want to avoid calling Assembly.LoadFile if the assembly has already be loaded once. Should I be concerned about calling Assembly.LoadFile repeatedly for a DLL that has already been loaded? Thanks.
Upvotes: 17
Views: 8601
Reputation: 30107
No you don't need to be concerned because if an assembly has already been loaded it won't be loaded again
If you call Assembly.LoadFile() then you can load the same assembly multiple times but only if you are loading assembly from different path each time. You can use Assembly.Load() which will load an assembly only once. You can also find about already loaded assemblies in current app domain using
Assembly[] asms = AppDomain.CurrentDomain.GetAssemblies();
Upvotes: 23
Reputation: 50235
For the given AppDomain, you can call GetAssemblies
and see if it's loaded.
Upvotes: 0