473,414 Members | 1,766 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,414 software developers and data experts.

Loading referenced types

Hi

I have a project that references one of our components, is there a way in
..Net to get a list of references that the application is depending on?

The reason for this is so I can load certain dlls on app startup.

Thanks
Kev
Jun 11 '06 #1
5 1754
You can find the assemblies that a given assembly references using
reflection, sort of like this:

System.Reflection.Assembly a =
System.Reflection.Assembly.GetExecutingAssembly();
foreach(System.Reflection.Assembly referenced in
a.GetReferencedAssemblies())
{
Console.WriteLine(referenced.GetName());
}

Mantorok wrote:
Hi

I have a project that references one of our components, is there a way in
.Net to get a list of references that the application is depending on?

The reason for this is so I can load certain dlls on app startup.

Thanks
Kev


Jun 11 '06 #2
Excellent, thanks.

Kev

"justncase80" <ju*********@gmail.com> wrote in message
news:11**********************@y43g2000cwc.googlegr oups.com...
You can find the assemblies that a given assembly references using
reflection, sort of like this:

System.Reflection.Assembly a =
System.Reflection.Assembly.GetExecutingAssembly();
foreach(System.Reflection.Assembly referenced in
a.GetReferencedAssemblies())
{
Console.WriteLine(referenced.GetName());
}

Mantorok wrote:
Hi

I have a project that references one of our components, is there a way in
.Net to get a list of references that the application is depending on?

The reason for this is so I can load certain dlls on app startup.

Thanks
Kev

Jun 12 '06 #3
Erm, that seemed to work at first but I noticed some references weren't
being returned from GetReferencedAssemblies(), do you know why this might
be?

Thanks
Kev

"justncase80" <ju*********@gmail.com> wrote in message
news:11**********************@y43g2000cwc.googlegr oups.com...
You can find the assemblies that a given assembly references using
reflection, sort of like this:

System.Reflection.Assembly a =
System.Reflection.Assembly.GetExecutingAssembly();
foreach(System.Reflection.Assembly referenced in
a.GetReferencedAssemblies())
{
Console.WriteLine(referenced.GetName());
}

Mantorok wrote:
Hi

I have a project that references one of our components, is there a way in
.Net to get a list of references that the application is depending on?

The reason for this is so I can load certain dlls on app startup.

Thanks
Kev

Jun 12 '06 #4
What assemblies are not loading? Are you sure that they're not all
loading? Maybe you're getting the references from the wrong assembly,
instead of getting it from GetExecutingASsembly() maybe try
GenEntryAssembly(). You can also load an assembly by path or from an
app domain. Check out this link from msdn2

http://msdn2.microsoft.com/en-us/lib...ssemblies.aspx

Let us know how it works out, if you have some quirks to resolve your
issue.

~justin

Mantorok wrote:
Erm, that seemed to work at first but I noticed some references weren't
being returned from GetReferencedAssemblies(), do you know why this might
be?

Thanks
Kev

"justncase80" <ju*********@gmail.com> wrote in message
news:11**********************@y43g2000cwc.googlegr oups.com...
You can find the assemblies that a given assembly references using
reflection, sort of like this:

System.Reflection.Assembly a =
System.Reflection.Assembly.GetExecutingAssembly();
foreach(System.Reflection.Assembly referenced in
a.GetReferencedAssemblies())
{
Console.WriteLine(referenced.GetName());
}

Mantorok wrote:
Hi

I have a project that references one of our components, is there a way in
.Net to get a list of references that the application is depending on?

The reason for this is so I can load certain dlls on app startup.

Thanks
Kev


Jun 13 '06 #5
Well, to be on the safe side I'm checking every non-GAC assembly in
AppDomain and loading all references from each one.

I've got a winforms project that references:

Ccc.Framework
Ccc.Proposable
System
System.configuration
System.Data
System.Design
System.Drawing
System.Windows.Forms
System.Xml

Yet GetReferencedAssemblies() only returns Ccc.Framework and System.....?!

Kev
"justncase80" <ju*********@gmail.com> wrote in message
news:11**********************@h76g2000cwa.googlegr oups.com...
What assemblies are not loading? Are you sure that they're not all
loading? Maybe you're getting the references from the wrong assembly,
instead of getting it from GetExecutingASsembly() maybe try
GenEntryAssembly(). You can also load an assembly by path or from an
app domain. Check out this link from msdn2

http://msdn2.microsoft.com/en-us/lib...ssemblies.aspx

Let us know how it works out, if you have some quirks to resolve your
issue.

~justin

Mantorok wrote:
Erm, that seemed to work at first but I noticed some references weren't
being returned from GetReferencedAssemblies(), do you know why this might
be?

Thanks
Kev

"justncase80" <ju*********@gmail.com> wrote in message
news:11**********************@y43g2000cwc.googlegr oups.com...
> You can find the assemblies that a given assembly references using
> reflection, sort of like this:
>
> System.Reflection.Assembly a =
> System.Reflection.Assembly.GetExecutingAssembly();
> foreach(System.Reflection.Assembly referenced in
> a.GetReferencedAssemblies())
> {
> Console.WriteLine(referenced.GetName());
> }
>
> Mantorok wrote:
>> Hi
>>
>> I have a project that references one of our components, is there a way
>> in
>> .Net to get a list of references that the application is depending on?
>>
>> The reason for this is so I can load certain dlls on app startup.
>>
>> Thanks
>> Kev
>

Jun 13 '06 #6

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

Similar topics

2
by: Che | last post by:
Greetings, I am writing an application that uses an extendible XML file. in order to validate that XML I use a main XSD and in additional - few more extensions XSD's that uses the types in the...
0
by: Deep Purple | last post by:
I started with the following error... ------------------------------------------------------- An error occured while loading the schema with TargetNamespace 'http://www.w3.org/2001/XMLSchema'...
9
by: Ender | last post by:
I have an application that I would like third party developers to be able to create Plug-ins that will be dynamically loaded into our application to extend functionality. I have utilized the...
0
by: Efkas | last post by:
I am trying some interresting features to load an assembly on the fly. I read some samples, but what I am trying to do is a little more complex. - First, I have a app.config file containing keys...
6
by: Pete Davis | last post by:
I'm confused about what precisely the limitations are on loading plugins in separate app domains. In all my previous apps that supported plugins, I've loaded them into the same domain as the app,...
2
by: Sri Prasad Tadimalla | last post by:
Is there a way to defer loading of a DLL until it is referenced by a method? Our product ships optional DLLs and we want to avoid writing wrapper classes to isolate calls to those DLLs. This is...
2
by: jnick | last post by:
I have the predicament of having to load several assemblies on the fly and when I do so, I get an exception stating that one of the referenced assemblies cannot be found. Is there any way to...
6
by: Jonas Huckestein | last post by:
hello, somehow i can't figure out, how to overload the operator for a referenced object. if i have class MyClass { int operator(int i) { return 1; }; };
2
by: davidkclark | last post by:
I see that this has been asked before, but there seem to be no (working) resolutions. I want to share the exact types used in webrequests between the client and the server. The proxy is too pale...
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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.