Re: Which referenes being used?

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance




"Brett" <no@xxxxxxxx> wrote in message
news:O4S1JazVFHA.2572@xxxxxxxxxxxxxxxxxxxxxxx
>
> "Willy Denoyette [MVP]" <willy.denoyette@xxxxxxxxxx> wrote in message
> news:uUDZDyyVFHA.2128@xxxxxxxxxxxxxxxxxxxxxxx
>>
>> "Bruce Wood" <brucewood@xxxxxxxxxx> wrote in message
>> news:1115925717.986868.169760@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
>>>>> Will removing the unused reference shrink the overall assembly size?
>>>
>>>
>>>> Not much if any size difference, but it will load a little faster
>>> since the
>>>> system doesn't need to locate and open the referenced assemblies.
>>>
>>> Do you mean that the C# compiler isn't smart enough not to insert code
>>> to load assemblies that aren't used by the code? I would have thought
>>> that either the compiler / CLR would load assemblies on "first use", so
>>> if you don't call them, they don't get loaded, or at least not build in
>>> code to load assemblies that aren't used in the code.
>>>
>>> The "first use" method would seem the most efficient: what if your
>>> program uses some large assembly but the user never takes an action
>>> that would cause it to be called? Would the CLR load it when your app
>>> starts up, anyway, even if the user never did anything that would
>>> require that assembly? Now I'm curious. :)
>>>
>>
>> You are right.
>> Only assemblies that are 'referenced' in code (have entries in the
>> assembly's Metadata) can be loaded implicitely. Assemblies that are
>> included in your project settings (used by the compiler) but aren't
>> referenced in code are simply ignored by the compiler, they aren't
>> included in the Metadata and cannot be loaded implicitely.
>
> Willy, where did you find this information? That's pretty good. I
> haven't read anything about that. Appreciate any references you can
> provide.
>
> Thanks,
> Brett
>

1.. Applied Microsoft .NET Framework Programming - J. Richter
2.. Shared Source CLI Essentials - Stutz, Neward and Shilling
3.. Essential .NET: Volume 1 - Don Box
4.. Inside Microsof .NET IL Assembler - S Lidin
5.. The Common Language Infrastructure Annotated Reference - J.Miller, AW
6.. Compiling for the .NET Common Language Runtime (CLR) - Gough
7.. ECMA CLI Partition Specs http://msdn.microsoft.com/net/ecma/
8.. MSDN, MSDN Magazine, Microsoft CLR Team Blogs
http://blogs.msdn.com/default.aspx, Debugging experiences etc...
Willy.



.



Relevant Pages

  • Re: 2 questions
    ... the list of current references in the project you can use Solution Explorer, ... Neither VS.NET nor the compiler "works this out". ... as you have 250+ assemblies in your "path". ... >> are referenced by the imports statement. ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Implications of circular references.
    ... Visual Studio doesn't like circular project references but the C# compiler is quite happy with circular assembly references ... Since the compiler gets its class / ... I've never tried putting the circular-referencing assemblies in ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Which referenes being used?
    ... >>> Not much if any size difference, but it will load a little faster ... >>> system doesn't need to locate and open the referenced assemblies. ... > included in your project settings (used by the compiler) but aren't ... Appreciate any references you can provide. ...
    (microsoft.public.dotnet.languages.csharp)
  • RE: control projects references
    ... Microsoft Online Support ... | Subject: RE: control project's references ... referenced assemblies are not compiled into the caller ...
    (microsoft.public.dotnet.framework.aspnet.buildingcontrols)
  • Re: Why does VS mark files as changed?
    ... assemblies that are used in multiple solutions. ...
    (microsoft.public.dotnet.framework.aspnet)