Determining location of assembly programmatically

  • Thread starter Thread starter kanepart2
  • Start date Start date
K

kanepart2

Hi,

I am coding in VB using VS 2003
If I have an assembly how can I determine if it should go into the
"C:\WINNT\assembly\GAC\" or the "C:\WINNT\assembly\GAC_MSIL\" or the
"C:\WINNT\assembly\GAC_32\" folder ...

thanks
 
I am coding in VB using VS 2003
If I have an assembly how can I determine if it should go into the
"C:\WINNT\assembly\GAC\" or the "C:\WINNT\assembly\GAC_MSIL\" or the
"C:\WINNT\assembly\GAC_32\" folder ...

All assemblies targeting .NET 1.1 should go into the GAC directory.

Why do you have to know that? If you use the appropriate APIs or tools
to add the assembly to the GAC it's not something you have to care
about.


Mattias
 
but when using .NET 2.0 then they are separated .. also .. i'm not
using any tools so i need to find out .. any hints would be greatly
appreciated .

thanks
 
but when using .NET 2.0 then they are separated ..

Right, but you said you were using VS 2003 which only targets .NET
1.1.

i'm not using any tools so i need to find out ..

Why not?

any hints would be greatly appreciated .

If an assembly is built for .NET 1.x (check
Assembly.ImageRuntimeVersion) then it should go into the GAC
directory.

If it targets .NET 2.0 or later, you can check the target platform
with Module.GetPEKind. The following table should tell you which
directory it ends up in in the GAC

PortableExecutableKinds Directory
----------------------- ---------
ILOnly GAC_MSIL
Required32Bit GAC_32
PE32Plus GAC_64

But note that the internal directory layout of the GAC is an
implementation detail that could change in the future. So I wouldn't
rely on this in my code.


Mattias
 
I am coding in VB using VS 2003
If I have an assembly how can I determine if it should go into the
"C:\WINNT\assembly\GAC\" or the "C:\WINNT\assembly\GAC_MSIL\" or the
"C:\WINNT\assembly\GAC_32\" folder ...

In all honesty, you shouldn't need to know.

GacUtil.exe, whose job it is to /put/ assemblies into the GAC, will work
this out for itself, as will the CLR when it goes looking for your
assembly to load it.

HTH,
Phill W.
 
Back
Top