PC Review


Reply
Thread Tools Rate Thread

Assembly.GetExecutingAssembly().GetReferencedAssemblies()

 
 
David Laub
Guest
Posts: n/a
 
      8th Jul 2004
It appears that getting a list of a program's referenced assemblies is a
dynamic/run-time facility.

If I execute GetReferencedAssemblies immediately in a console app, the only
assemblies returned are the app itself and mscorlib

If I (recursively) execute GetReferencedAssemblies after methods in
referenced assemblies have been resolved/executed, then I get a far more
meaningful list

I would really like a method which reflects the "full" static reference list
in the c# project file. Does such a method exist, or is there a good way to
simulate this?

Thanks

David Laub (E-Mail Removed)





Assembly.GetExecutingAssembly().GetReferencedAssemblies()


 
Reply With Quote
 
 
 
 
Mattias Sjögren
Guest
Posts: n/a
 
      9th Jul 2004
David,

>I would really like a method which reflects the "full" static reference list
>in the c# project file. Does such a method exist, or is there a good way to
>simulate this?


The C# compiler only writes AssemblyRef records (which is what
GetReferencedAssemblies retrieves) for assemblies that you actually
use. If you reference a bunch of assemblies that you don't use in your
code, that will not be seen in the compiled assembly. The only way to
discover such references would be to parse the .csproj project file.



Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
 
Reply With Quote
 
=?Utf-8?B?U2hyaSBCb3JkZSBbTVNd?=
Guest
Posts: n/a
 
      10th Jul 2004
This is the same information as shown by ildasm.exe in the "Manifest".

Shri Borde [MSFT]

This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
> From: Mattias Sjögren <(E-Mail Removed)>
> Subject: Re: Assembly.GetExecutingAssembly().GetReferencedAssemblies()
> Date: Fri, 09 Jul 2004 02:09:18 +0200
> References: <#(E-Mail Removed)>
> X-Newsreader: Forte Agent 1.8/32.548
> MIME-Version: 1.0
> Content-Type: text/plain; charset=ISO-8859-1
> Content-Transfer-Encoding: 8bit
> Message-ID: <ee$(E-Mail Removed)>
> Newsgroups: microsoft.public.dotnet.framework
> NNTP-Posting-Host: g150.ryd.student.liu.se 130.236.238.150
> Lines: 1
> Path:

cpmsftngxa06.phx.gbl!TK2MSFTNGXA01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP12
.phx.gbl
> Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework:75370
> X-Tomcat-NG: microsoft.public.dotnet.framework
>
> David,
>
> >I would really like a method which reflects the "full" static reference

list
> >in the c# project file. Does such a method exist, or is there a good

way to
> >simulate this?

>
> The C# compiler only writes AssemblyRef records (which is what
> GetReferencedAssemblies retrieves) for assemblies that you actually
> use. If you reference a bunch of assemblies that you don't use in your
> code, that will not be seen in the compiled assembly. The only way to
> discover such references would be to parse the .csproj project file.
>
>
>
> Mattias
>
> --
> Mattias Sjögren [MVP] mattias @ mvps.org
> http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
> Please reply only to the newsgroup.
>


 
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
Assembly.GetExecutingAssembly(). csharpula csharp Microsoft C# .NET 3 15th May 2008 04:39 PM
Assembly.GetExecutingAssembly Bruce Microsoft Dot NET Framework 2 14th Jul 2006 09:09 PM
Assembly.GetExecutingAssembly Bruce Microsoft Dot NET 1 14th Jul 2006 09:09 PM
Assembly.GetReferencedAssemblies Mythran Microsoft C# .NET 3 25th May 2006 07:49 PM
System.Reflection.Assembly.GetExecutingAssembly() =?Utf-8?B?UGF0cmljaw==?= Microsoft Dot NET 1 29th Dec 2005 02:19 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:12 PM.