473,242 Members | 1,570 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,242 software developers and data experts.

Determine if Assembly Is Loaded

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.

Jun 27 '08 #1
1 5947
You could always use the Load(AssemblyName) method, which would ensure that
the assembly is loaded. You cannot load an assembly into an appDomain more
than once.
-- Peter
To be a success, arm yourself with the tools you need and learn how to use
them.

Site: http://www.eggheadcafe.com
http://petesbloggerama.blogspot.com
http://ittyurl.net
"Verde" wrote:
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.

Jun 27 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Daylor | last post by:
can shadowcopy be done with private assembly ? any info about how shadowcopy actually works ? when im compiling an assembly (while the assembly file is in use ), what i need to do ? change...
11
by: Z D | last post by:
Hello, If I have a .NET assembly, how do I determine what version of the .NET framework it.... 1) was compiled against 2) is supposed to use 3) is compatible with? Is there a utility that...
1
by: Benjamin | last post by:
Hi, I'm currently writing a Web Services that interacts with a database. To allow me to use not just one database provider (for example, I could use MS Access, SQL Server or MySQL), the Web...
1
by: James Wansley | last post by:
I am currently running a c# service that dynamically loads assemblies using System.Reflection.Assembly.LoadFrom("aDll.dll"). These assemblies are stored in an arraylist after they are loaded. I...
1
by: Zachary Hartnett | last post by:
I was trying to write a routine this morning that would open a given assembly, walk the inheritance tree of classes in the assembly, and provide a list of classes in the assembly that inherit from...
2
by: Jan | last post by:
Regarding my post "CSharpCodeProvider: referencing other generated "InMemory" assembly" 4/27/2006 and the blog from Greg Young http://geekswithblogs.net/gyoung/archive/2006/04/27/76533.aspx I...
4
by: Object01 | last post by:
We're working with some benchmarks designed to test x86 vs. x64 performance (both on a x64 system). To ensure that our assemblies are loaded as x86 or x64, we specifically target our builds to the...
12
by: =?Utf-8?B?Um9nZXIgTWFydGlu?= | last post by:
I am writing a web app to be widely distributed where I do not know the installed .NET Framework version. I want to take advantage of some .NET 3.0 classes if they are installed, but gracefully...
7
by: Cramer | last post by:
I'm wondering if there is an easy way to programmatically determine if an assembly is installed in the GAC. This would be similar to our ability to easily determine if a file exists...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.