GAC and NGEN

T

Techno_Dex

What are the advantages of GACing then NGENing an assembly as opposed to
just NGENing an assembly? My understanding is the GAC is to be used as a
versioning respository for common assemblies used by multiple applications
and NGENing is to create a native compiled copy of the assembly so it is
optimized to run faster on the given machine. Since NGEN is just a special
section within the GAC, is there really a need to GAC then NGEN or is NGEN
good enough? Is this dependent or independent of the assembly being a
common among multiple applications?
 
A

Alvin Bruney [ASP.NET MVP]

The two aren't really related. GAC'ing refers to placing a static copy of
the image in a particular place. NGEN is really about placing a compiled
image of the assembly and its dependencies into the native cache for use at
run-time. For that reason, you can ngen and gac'd assembly although there
are some corner cases to be aware of. See this link for the scoop
http://msdn.microsoft.com/en-us/library/6t9t5wcf(VS.80).aspx

--

Regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
Download OWC Black Book, 2nd Edition
Exclusively on www.lulu.com/owc $15.00
Need a free copy of VSTS 2008 w/ MSDN Premium?
http://msmvps.com/blogs/alvin/Default.aspx
 
T

Techno_Dex

This is partly why I'm a little confused about this subject, the native
image cache is just a special section within the Global Assembly Cache. You
can GAC an Assembly, NGEN an assembly or GAC an Assembly then NGEN that same
assembly if you use the "Display Name" which you retrieve from the GAC when
NGENing the assembly. When you say GACing is placing a static copy of the
image in an particular place, my understanding is this is for sharing
purposes so more than one application can can access the same assembly with
a specific version in order to avoid DLL Hell in the event someone installs
a new copy of the same assembly over the top of the original one on disk.
By GACing, there is a custom calculated name created in the GAC to store
each versioned copy. The only thing I can come up with is if you NGEN an
assembly there is an optimized copy put into the Native Image Cache (AKA
special section of the GAC) where no other applications and or vendors can
access your assembly??? But then I read that NGEN'd files can be accessed
across application domains which tosses that notion out the window. What am
I missing?


Alvin Bruney said:
The two aren't really related. GAC'ing refers to placing a static copy of
the image in a particular place. NGEN is really about placing a compiled
image of the assembly and its dependencies into the native cache for use
at run-time. For that reason, you can ngen and gac'd assembly although
there are some corner cases to be aware of. See this link for the scoop
http://msdn.microsoft.com/en-us/library/6t9t5wcf(VS.80).aspx

--

Regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
Download OWC Black Book, 2nd Edition
Exclusively on www.lulu.com/owc $15.00
Need a free copy of VSTS 2008 w/ MSDN Premium?
http://msmvps.com/blogs/alvin/Default.aspx
-------------------------------------------------------


Techno_Dex said:
What are the advantages of GACing then NGENing an assembly as opposed to
just NGENing an assembly? My understanding is the GAC is to be used as a
versioning respository for common assemblies used by multiple
applications and NGENing is to create a native compiled copy of the
assembly so it is optimized to run faster on the given machine. Since
NGEN is just a special section within the GAC, is there really a need to
GAC then NGEN or is NGEN good enough? Is this dependent or independent
of the assembly being a common among multiple applications?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top