PC Review


Reply
Thread Tools Rate Thread

How can I get the source path of referenced assembly?

 
 
Leo Pedeglorio
Guest
Posts: n/a
 
      28th Jan 2004
Hi Everyone!

How can I get the source path of referenced assembly?

Source path - it is where the reference assembly or dll will be searched
when the solution is being rebuild.
You can see it when you right click a referenced assembly under a project
and select properties from the
context menu. From the properties window, there you will see the source
path.
But I want to get it inside my code. But how?

Thanks a lot!



 
Reply With Quote
 
 
 
 
Kapil Sachdeva
Guest
Posts: n/a
 
      28th Jan 2004
Location property of System.Reflection.Assembly class will help you find the
path of the assembly.

regards
Kapil

"Leo Pedeglorio" <(E-Mail Removed)> wrote in message
news:#(E-Mail Removed)...
> Hi Everyone!
>
> How can I get the source path of referenced assembly?
>
> Source path - it is where the reference assembly or dll will be searched
> when the solution is being rebuild.
> You can see it when you right click a referenced assembly under a project
> and select properties from the
> context menu. From the properties window, there you will see the source
> path.
> But I want to get it inside my code. But how?
>
> Thanks a lot!
>
>
>



 
Reply With Quote
 
Manoj G [MVP]
Guest
Posts: n/a
 
      28th Jan 2004
The source path of a referenced assembly is never a part of the assembly
metadata(manifest). The actual path of the referenced assembly is only
resolved at rutime (which in itself is a complicated process) and this is
what is available through reflection. So, you may be loading an referenced
assembly different from the one which you have referenced (located in a
different folder) at runtime.

For getting a list of referenced assemblies, you may want to look at the
collection got from [Assembly].GetExecutingAssembly.GetReferencedAssemblies
method.

--
HTH,
Manoj G [.NET MVP]
Site: http://www15.brinkster.com/manoj4dotnet
Blog: http://msmvps.com/manoj/

"Kapil Sachdeva" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Location property of System.Reflection.Assembly class will help you find

the
> path of the assembly.
>
> regards
> Kapil
>
> "Leo Pedeglorio" <(E-Mail Removed)> wrote in message
> news:#(E-Mail Removed)...
> > Hi Everyone!
> >
> > How can I get the source path of referenced assembly?
> >
> > Source path - it is where the reference assembly or dll will be searched
> > when the solution is being rebuild.
> > You can see it when you right click a referenced assembly under a

project
> > and select properties from the
> > context menu. From the properties window, there you will see the source
> > path.
> > But I want to get it inside my code. But how?
> >
> > Thanks a lot!
> >
> >
> >

>
>



 
Reply With Quote
 
Manoj G [MVP]
Guest
Posts: n/a
 
      28th Jan 2004
Apologies for my rather confusing sentance below. Here's the correction:

So, at runtime, you may be loading an assembly different from the one which
you have referenced at design time (located in a different folder/maybe
GAC).


--
HTH,
Manoj G [.NET MVP]
Site: http://www15.brinkster.com/manoj4dotnet
Blog: http://msmvps.com/manoj/

"Manoj G [MVP]" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> The source path of a referenced assembly is never a part of the assembly
> metadata(manifest). The actual path of the referenced assembly is only
> resolved at rutime (which in itself is a complicated process) and this is
> what is available through reflection. So, you may be loading an referenced
> assembly different from the one which you have referenced (located in a
> different folder) at runtime.
>
> For getting a list of referenced assemblies, you may want to look at the
> collection got from

[Assembly].GetExecutingAssembly.GetReferencedAssemblies
> method.
>
> --
> HTH,
> Manoj G [.NET MVP]
> Site: http://www15.brinkster.com/manoj4dotnet
> Blog: http://msmvps.com/manoj/
>
> "Kapil Sachdeva" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > Location property of System.Reflection.Assembly class will help you find

> the
> > path of the assembly.
> >
> > regards
> > Kapil
> >
> > "Leo Pedeglorio" <(E-Mail Removed)> wrote in message
> > news:#(E-Mail Removed)...
> > > Hi Everyone!
> > >
> > > How can I get the source path of referenced assembly?
> > >
> > > Source path - it is where the reference assembly or dll will be

searched
> > > when the solution is being rebuild.
> > > You can see it when you right click a referenced assembly under a

> project
> > > and select properties from the
> > > context menu. From the properties window, there you will see the

source
> > > path.
> > > But I want to get it inside my code. But how?
> > >
> > > Thanks a lot!
> > >
> > >
> > >

> >
> >

>
>



 
Reply With Quote
 
Gaurav Khanna [C# MVP]
Guest
Posts: n/a
 
      28th Jan 2004
Hi!

Assembly.GetReferencedAssemblies will return you an array of AssemblyName.
Use the CodeBase property of AssemblyName to get the path to the assembly in
question.

Ofcourse, if Configuration Policies are in place and they redirect calls to
a different assembly, then you wont get the redirected-to-assembly name.

--
Regards,
Kumar Gaurav Khanna
-----------------------------------------------------------------
Microsoft MVP - C#/.NET, MCSE Windows 2000/NT4, MCP+I
WinToolZone - Spelunking Microsoft Technologies
http://www.wintoolzone.com/
OpSupport - Spelunking Rotor
http://opsupport.sscli.net/
Bangalore .NET Users' Group
http://groups.msn.com/bdotnet/
"Leo Pedeglorio" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> Hi Everyone!
>
> How can I get the source path of referenced assembly?
>
> Source path - it is where the reference assembly or dll will be searched
> when the solution is being rebuild.
> You can see it when you right click a referenced assembly under a project
> and select properties from the
> context menu. From the properties window, there you will see the source
> path.
> But I want to get it inside my code. But how?
>
> Thanks a lot!
>
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Crystal Reports: How to select data source from a referenced assembly in "Database Expert" window? john Microsoft Dot NET 2 25th Jul 2006 05:37 PM
Unable to emit assembly: Referenced assembly 'App_WebReference.... =?Utf-8?B?ZWhlaW5zZW4=?= Microsoft Dot NET 0 15th Mar 2006 05:26 PM
Assembly generation failed -- Referenced assembly 'Interop.SHDocVw' does not have a strong name jm Microsoft C# .NET 0 26th May 2004 09:55 PM
Re:Source Path of Referenced Assembly Leo Pedeglorio Microsoft Dot NET Framework 0 27th Jan 2004 09:59 AM
Source Path of Referenced Assembly Leo Pedeglorio Microsoft Dot NET Framework 1 27th Jan 2004 09:38 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:10 PM.