Assembly registered in GAC but not accessible from VS

J

Joannes Vermorel

Hi,

I have produced a strong name assembly MyLib.dll, and registered this
assembly with "gacutil -i MyLib.dll". The assembly appears correctly in the
"windows/assembly" directory.

However, the assembly does not appear in the list of assemblies provided by
Visual Studio from "My Project => Add reference" (in C#). This seems a bit
weird to me. I was thinking that the proposed list was precisely the GAC.
But it does not seems so since my assembly "MyLib.dll" does not appear in
this list.

What should I do to make "MyLib.dll" appears in the "Add reference" assembly
list in VS ?

Thanks,
Joannes
 
M

mikeb

Joannes said:
Hi,

I have produced a strong name assembly MyLib.dll, and registered this
assembly with "gacutil -i MyLib.dll". The assembly appears correctly in the
"windows/assembly" directory.

However, the assembly does not appear in the list of assemblies provided by
Visual Studio from "My Project => Add reference" (in C#). This seems a bit
weird to me. I was thinking that the proposed list was precisely the GAC.
But it does not seems so since my assembly "MyLib.dll" does not appear in
this list.

I agree with you that it's weird, but it's by design.
What should I do to make "MyLib.dll" appears in the "Add reference" assembly
list in VS ?

The method that is probably most usually used is to simply have a copy
of the assembly somewhere on the file system (in addition to the one in
the GAC), and browse for the assembly in the Add Reference dialog.

If you absolutely want to have the assembly automatically show up in the
dialog list, then you have to place it in a directory (again other
than in the GAC) and place a pointer to that directory in the registry:

HKLM\SOFTWARE\Microsoft\VisualStudio\7.1\AssemblyFolders

Look at the entries that are already there, and it should be clear
exactly what you need to do.
 
C

Chris Fink

"The method that is probably most usually used is to simply have a
copy
of the assembly somewhere on the file system (in addition to the one
in
the GAC), and browse for the assembly in the Add Reference dialog."

Doesn't this defeat the purpose of the GAC? If this method is used,
how do you ensure that everyone is using the correct version of the
assembly? Sounds very odd to me.
 
M

mikeb

Chris said:
"The method that is probably most usually used is to simply have a
copy
of the assembly somewhere on the file system (in addition to the one
in
the GAC), and browse for the assembly in the Add Reference dialog."

Doesn't this defeat the purpose of the GAC? If this method is used,
how do you ensure that everyone is using the correct version of the
assembly? Sounds very odd to me.

You'll have to get word from Microsoft for a definitive answer on this.

As far as I'm concerned, it's better to refer to assemblies that are not
in the GAC - it makes it much easier to have build environments that can
be pulled down from version control, and have the build 'just work' - no
need to register stuff in the GAC (like what might need to be done with
COM components). Although having to have VS.NET installed to do the
build sort of defeats the ability to do this.

However, I don't think it's unreasonable for developers to expect VS.NET
to provide for referring to assemblies in the GAC. But that's not how it
works; other posts have made it clear that this is 'as designed', and as
far as I know this has not changed in the pre-release versions of VS.NET
2005.
 

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