is there something like:
AppDomain.CurrentDomain.GetAssemblyByName("TheAssemblyName")
so instead of looping through AppDomain.CurrentDomain.GetAssemblies()
, we could just get the specific assembly directly...
Thank you!
is there something like:
AppDomain.CurrentDomain.GetAssemblyByName("TheAssemblyName")
so instead of looping through AppDomain.CurrentDomain.GetAssemblies()
, we could just get the specific assembly directly...
Thank you!
Have you tried looking at Assembly.Load(...)?
P.S. Snowmen fall from heaven... unassembled. (yes, first day of snow in Denmark) :D
Have a look at the System.Reflection.Assembly class, in particular the Load method: MSDN
It depends on what you're trying to accomplish.
If you just want to get the assembly, then you should call System.Reflection.Assembly.Load()
(as already pointed out). That's because .NET automatically checks if the assembly has already been loaded into the current AppDomain and doesn't load it again if it has been.
If you're just trying to check whether the assembly has been loaded or not (for some diagnostics reason, perhaps) then you do have to loop over all the loaded assemblies.
Another reason you might want to loop is if you know only some of the assembly information (eg. you're not sure of the version). That is, you know enough to "recognise it when you see it", but not enough to load it. That is a fairly obscure and unlikely scenario, though.