473,662 Members | 2,406 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1773
You can find the assemblies that a given assembly references using
reflection, sort of like this:

System.Reflecti on.Assembly a =
System.Reflecti on.Assembly.Get ExecutingAssemb ly();
foreach(System. Reflection.Asse mbly referenced in
a.GetReferenced Assemblies())
{
Console.WriteLi ne(referenced.G etName());
}

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

"justncase8 0" <ju*********@gm ail.com> wrote in message
news:11******** **************@ y43g2000cwc.goo glegroups.com.. .
You can find the assemblies that a given assembly references using
reflection, sort of like this:

System.Reflecti on.Assembly a =
System.Reflecti on.Assembly.Get ExecutingAssemb ly();
foreach(System. Reflection.Asse mbly referenced in
a.GetReferenced Assemblies())
{
Console.WriteLi ne(referenced.G etName());
}

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 GetReferencedAs semblies(), do you know why this might
be?

Thanks
Kev

"justncase8 0" <ju*********@gm ail.com> wrote in message
news:11******** **************@ y43g2000cwc.goo glegroups.com.. .
You can find the assemblies that a given assembly references using
reflection, sort of like this:

System.Reflecti on.Assembly a =
System.Reflecti on.Assembly.Get ExecutingAssemb ly();
foreach(System. Reflection.Asse mbly referenced in
a.GetReferenced Assemblies())
{
Console.WriteLi ne(referenced.G etName());
}

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 GetExecutingASs embly() maybe try
GenEntryAssembl y(). 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 GetReferencedAs semblies(), do you know why this might
be?

Thanks
Kev

"justncase8 0" <ju*********@gm ail.com> wrote in message
news:11******** **************@ y43g2000cwc.goo glegroups.com.. .
You can find the assemblies that a given assembly references using
reflection, sort of like this:

System.Reflecti on.Assembly a =
System.Reflecti on.Assembly.Get ExecutingAssemb ly();
foreach(System. Reflection.Asse mbly referenced in
a.GetReferenced Assemblies())
{
Console.WriteLi ne(referenced.G etName());
}

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.configur ation
System.Data
System.Design
System.Drawing
System.Windows. Forms
System.Xml

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

Kev
"justncase8 0" <ju*********@gm ail.com> wrote in message
news:11******** **************@ h76g2000cwa.goo glegroups.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 GetExecutingASs embly() maybe try
GenEntryAssembl y(). 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 GetReferencedAs semblies(), do you know why this might
be?

Thanks
Kev

"justncase8 0" <ju*********@gm ail.com> wrote in message
news:11******** **************@ y43g2000cwc.goo glegroups.com.. .
> You can find the assemblies that a given assembly references using
> reflection, sort of like this:
>
> System.Reflecti on.Assembly a =
> System.Reflecti on.Assembly.Get ExecutingAssemb ly();
> foreach(System. Reflection.Asse mbly referenced in
> a.GetReferenced Assemblies())
> {
> Console.WriteLi ne(referenced.G etName());
> }
>
> 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
2183
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 main XSD as base types. my clients can define their own XSD's extensions and use my generic application to process their XML's. The problem:
0
1572
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' referenced in this document. The value for the 'base' attribute is invalid - 'xsd:string' is an invalid value for the 'base' attribute. An error occured at the file:///C:Program Files/Microsoft Visual Studio .NET 2003...
9
4475
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 "Let Users Add Functionality to Your .NET Applications with Macros and Plug-Ins" article at MSDN for the dynamic loading of DLLs http://msdn.microsoft.com/msdnmag/issues/03/10/Plug-Ins/default.aspx
0
1407
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 like "mydll_MyClass.dll" - Second, I tried to load the assembly with Assembly.LoadFrom(myDll), but since my constructor having some parameters this is not possible. - Third, I tried Activator.CreateInstance(...), but it becomes very
6
4498
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, but I've just started playing around with separate AppDomains and I'm finding that I'm not having problems where I expected I would, so maybe someone can help me understand a bit better. I've read that objects instantiated in separate AppDomains...
2
1600
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 becoming cumbersome as we develop more licensed components. Perhaps there is a way to protect this code in some kind of tag? Thanks, Prasad
2
2636
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 recurse into an assembly to discover the referenced assemblies without actually loading the root assembly where I start the load? For example: assembly 1 contains references to assembly 1_1 and assembly 1_2 assembly 1_1 contains reference to...
6
1810
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
2850
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 a representation of the actual class used by the server: there are useful functions like ToString overrides etc that I want the client to use. So when I create the service reference (VS 2008) I check the advanced option to reuse the types,...
0
8432
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8343
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8762
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8545
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8633
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6185
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4179
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2762
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1747
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.