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.
AssemblyResolve event, to handle the attempt to load an assembly when the automatic CLR search has failed.
To load an assembly from a byte array with the trust level of the application domain, use the Load(Byte[], Byte[], SecurityContextSource) method overload.
You can not unload an assembly from an appdomain. You can destroy appdomains, but once an assembly is loaded into an appdomain, it's there for the life of the appdomain.
LoadFrom(String) Loads an assembly given its file name or path.
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();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With