473,406 Members | 2,705 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,406 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 5998
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.