Determine if Assembly Is Loaded

  • Thread starter Thread starter Verde
  • Start date Start date
V

Verde

Is there an easier way to determine if a specific assembly is loaded into
the current AppDomain?

I'm thinking that there has to be a way to do it without looping through all
currently loaded assemblies, yet I couldn't find how to do it without
looping.

This is what I have:

private bool AssemblyIsLoaded(string pathToAssembly)
{
foreach (Assembly currentAssembly in
AppDomain.CurrentDomain.GetAssemblies())
{
try // This try/catch block is necessary because the .Location
property is not supported in a dynamic assembly.
{
if (currentAssembly.Location.Equals(pathToAssembly,
StringComparison.OrdinalIgnoreCase))
{
return true;
}
}
catch (Exception ex) { }
}

return false;
}


Thanks in advance.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top