GAC entries don't show up in References/.NET

  • Thread starter Thread starter Ricola !
  • Start date Start date
R

Ricola !

Two c# dll's were compiled and added to the GAC.

They appear in the .NET Configuration tool.

However, when trying to add a reference to a new project, the dlls do
not appear in the .NET property sheet.

Why not?


--
Texeme Textcasting Technology
http://texeme.com

Indie Pop Rocks @ SomaFM
http://somafm.com/
 
John said:
Confused? what .Net property sheet are you meaning here?

John,

Take a VS.NET project.

Right click on references.

There are three property sheets:

..NET
COM
Projects

On the .NET property sheet, when you scroll through the list -- I would
expect to see every assembly that is in the GAC.

I see my two assemblies in the GAC.
But they do not show up in this list.

The real problem is that when I deploy my windows service, which calls a
DLL that references another DLL an error is thrown and the second DLL
cannot be found!

The first one can!

Both are in a folder in Program files and contained in the GAC.

The *.exe service resides in it's own folder on both the target server
and on my workstation.

I made the folder names and everything else exactly the same.

I cleaned up and deleted each and every other copy of the dlls ( debug
versions ).

My workstation is XP; the server is W2k.

On my workstation, the service can find the first dll, and then it can
find the second.

On the target server, the service can find the first dll, but it throws
an error saying it cannot find the second.

Very puzzling...


--
Texeme Textcasting Technology
http://texeme.com

Indie Pop Rocks @ SomaFM
http://somafm.com/
 
If you cant find them on the ".Net" tab, you should be able to click the
"browse" button and locate your component and then include it.

Ab.
 
On the .NET property sheet, when you scroll through the list -- I would
expect to see every assembly that is in the GAC.

Well you shouldn't, the Add Refefence dialog doesn't list the content
of the GAC.

The real problem is that when I deploy my windows service, which calls a
DLL that references another DLL an error is thrown and the second DLL
cannot be found!

You can use the Fuslogvw.exe tool to diagnose binding errors.



Mattias
 
There are three property sheets:
you can also call them "tabs"
Both are in a folder in Program files and contained in the GAC.
when you deploy .net stuff(assemblies) to other machines these kind of
folder dependencies should not be a problem. Lets say dll1 needs dll2 to
run, then if the dll1 can find dll2 in its own dir than its fine and will
use it, but if its not there than the dll2 maybe a strongly typed assembly
and dll1 should be able to find it if dll2 is registered in the gac.
I made the folder names and everything else exactly the same.
no need to do this
On the target server, the service can find the first dll, but it throws
an error saying it cannot find the second.
I also maybe missing something as I havnt ever made a windows service and
deployed it. I cannot think of any other situation why your dlls are not
getting located. Maybe versioning would be a problem but I'm not sure about
that. But try a little exercise to be sure that what u r doing is right.
Simply make 2 dlls (.net dlls) where dll1 uses some function of dll2. Now
create an exe (windows forms or console) and call some function of the dll1
(which calls dll2). now deploy these assemblies in your XP machine ( I
assume that you would be using that win2k machine as dev machine). Things
should work.

Ab.
 
Hi,

The contents of the "Add Reference" list of assemblies is populated from the
PublicAssemblies folder under the Visual Studio .NET's installation folder
(something like Common7\IDE\PublicAssemblies).
 
Dmitriy said:
Hi,

The contents of the "Add Reference" list of assemblies is populated from
the PublicAssemblies folder under the Visual Studio .NET's installation
folder (something like Common7\IDE\PublicAssemblies).

... and the assemblies found in the paths stored under teh following
registry hive:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\AssemblyFolders

Just add a folder there as a key, with a REG_SZ value as the default
value and that value is the full path.

Frans

--
 
Abubakar said:
I also maybe missing something as I havnt ever made a windows service and
deployed it. I cannot think of any other situation why your dlls are not
getting located. Maybe versioning would be a problem but I'm not sure about
that. But try a little exercise to be sure that what u r doing is right.
Simply make 2 dlls (.net dlls) where dll1 uses some function of dll2. Now
create an exe (windows forms or console) and call some function of the dll1
(which calls dll2). now deploy these assemblies in your XP machine ( I
assume that you would be using that win2k machine as dev machine). Things
should work.

That describes exactly what I'm doing.

The results are ( and I use your names for the sake of readability ):

On the <b>XP</b> machine ( development workstation ) it runs fine --
even if I completely shut down studio and run it normally.

myExe calls dll1 which calls dll2

myEexe is located in \program files\myExe

dll1 and dll2 are located in \program files\myDLLs

dll1 and dll2 have strong names and are registered in the GAC

However, when I move this structure to a target <b>w2k</b> server, dll1
fails to find dll2, generating the error:

2/8/2005 6:56:01 PM: CS0006: Metadata file 'dll2' could not be found


I have searched and deleted all extra copies of myExe, dll1 and dll2 on
both machines.

--
Texeme Textcasting Technology
http://texeme.com

Indie Pop Rocks @ SomaFM
http://somafm.com/
 
Ok, I found a fix...I thought about it while riding my bicycle to
Tully's to get a coffee.

I put the 2nd dll in the \winnt\system32 directory.

So, for some reason, when a dll calls a 2nd dll.

My theory is that when a dll "runs", it's actually running in
\winnt\system32

And also, it would mean that a strongly named dll, registered in the
GAC, cannot be called by another dll.

I'd really like someone from Microsoft to prove me wrong on this, as I
suspect is a very major bug in the .NET assembly configuration
management(!)

That describes exactly what I'm doing.

The results are ( and I use your names for the sake of readability ):

On the <b>XP</b> machine ( development workstation ) it runs fine --
even if I completely shut down studio and run it normally.

myExe calls dll1 which calls dll2

myEexe is located in \program files\myExe

dll1 and dll2 are located in \program files\myDLLs

dll1 and dll2 have strong names and are registered in the GAC

However, when I move this structure to a target <b>w2k</b> server, dll1
fails to find dll2, generating the error:

2/8/2005 6:56:01 PM: CS0006: Metadata file 'dll2' could not be found


I have searched and deleted all extra copies of myExe, dll1 and dll2 on
both machines.


--
Texeme Textcasting Technology
http://texeme.com

Indie Pop Rocks @ SomaFM
http://somafm.com/
 
I put the 2nd dll in the \winnt\system32 directory.
this is another location where the search is done
And also, it would mean that a strongly named dll, registered in the
GAC, cannot be called by another dll.

I'd really like someone from Microsoft to prove me wrong on this, as I
suspect is a very major bug in the .NET assembly configuration
management(!)
ok so now i had to do an experiment, prepare a code and upload it for your
convenience. I'll give u a simple experiment to do now with assemblies built
by me.
Download the files from here http://www.geocities.com/abubakar021/help.zip.
Extract the files and you'll find a folder named "runfromGAC". It has a
ConsoleApplication1.exe and 2 folders named d1 and d2. Check this:
ConsoleApplication1.exe calls dll1 which calls dll2. Now notice this that
you only have ConsoleApplication1.exe in the root folder and there is no dll
there, so ConsoleApplication1.exe does NOT know where its dependencies are
located which I'm going to demo you. Open a command prompt and browse to the
dir where your ConsoleApplication1.exe is and run it by typing
"ConsoleApplication1.exe" on the command prompt (without quotes of course).
You'll receieve the following error:

+++++++++++++++++++
Unhandled Exception: System.IO.FileNotFoundException: File or assembly name
ClassLibrary1, or one of its dependenci
es, was not found.
File name: "ClassLibrary1"
at ConsoleApplication1.Class1.Main(String[] args)

=== Pre-bind state information ===
LOG: DisplayName = ClassLibrary1, Version=1.0.1867.29218, Culture=neutral,
PublicKeyToken=59c3da0b75007a93
(Fully-specified)
LOG: Appbase = D:\tempcode\experiment\Run\runfromGAC\
LOG: Initial PrivatePath = NULL
Calling assembly : ConsoleApplication1, Version=1.0.1867.29219,
Culture=neutral, PublicKeyToken=null.
===

LOG: Application configuration file does not exist.
LOG: Publisher policy file is not found.
LOG: Host configuration file not found.
LOG: Using machine configuration file from
C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\config\machine.config.
LOG: Post-policy reference: ClassLibrary1, Version=1.0.1867.29218,
Culture=neutral, PublicKeyToken=59c3da0b75007a93

LOG: Attempting download of new URL
file:///D:/tempcode/experiment/Run/runfromGAC/ClassLibrary1.DLL.
LOG: Attempting download of new URL
file:///D:/tempcode/experiment/Run/runfromGAC/ClassLibrary1/ClassLibrary1.DL
L.
LOG: Attempting download of new URL
file:///D:/tempcode/experiment/Run/runfromGAC/ClassLibrary1.EXE.
LOG: Attempting download of new URL
file:///D:/tempcode/experiment/Run/runfromGAC/ClassLibrary1/ClassLibrary1.EX
E.
+++++++++++++++++++
NOTE: the paths before "runfromGAC" are my machine specific, they'll be diff
on yours.

Read the error, its clear that the class lib 1 is missing. If we register it
this error should go away right? So thats what we r going to do. Now goto
your Control Panel->Administrative Tools. Double click the "Microsoft .NET
Framework 1.1 Configuration". Right click the "Assembly Cache" node and
click "Add ...". Locate the dll1 from "d1" folder and click "Open" and now
the ClassLibrary1.dll is in gac. Now back to command prompt. run the
ConsoleApplication1.exe again. Now you see a similar error as before but its
not the same. Notice now its the following:
+++++++++++++++
Unhandled Exception: System.IO.FileNotFoundException: File or assembly name
ClassLibrary2, or one of its dependenci
es, was not found.
File name: "ClassLibrary2"
at ClassLibrary1.Class1.getCL2data()
at ConsoleApplication1.Class1.Main(String[] args)

=== Pre-bind state information ===
LOG: DisplayName = ClassLibrary2, Version=1.0.1867.29085, Culture=neutral,
PublicKeyToken=3727e4d9d6b9561c
(Fully-specified)
LOG: Appbase = D:\tempcode\experiment\Run\runfromGAC\
LOG: Initial PrivatePath = NULL
Calling assembly : ClassLibrary1, Version=1.0.1867.29218, Culture=neutral,
PublicKeyToken=59c3da0b75007a93.
===

LOG: Publisher policy file is not found.
LOG: Host configuration file not found.
LOG: Using machine configuration file from
C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\config\machine.config.
LOG: Post-policy reference: ClassLibrary2, Version=1.0.1867.29085,
Culture=neutral, PublicKeyToken=3727e4d9d6b9561c

LOG: Attempting download of new URL
file:///D:/tempcode/experiment/Run/runfromGAC/ClassLibrary2.DLL.
LOG: Attempting download of new URL
file:///D:/tempcode/experiment/Run/runfromGAC/ClassLibrary2/ClassLibrary2.DL
L.
LOG: Attempting download of new URL
file:///D:/tempcode/experiment/Run/runfromGAC/ClassLibrary2.EXE.
LOG: Attempting download of new URL
file:///D:/tempcode/experiment/Run/runfromGAC/ClassLibrary2/ClassLibrary2.EX
E.
+++++++++++++++
NOTE: the paths before "runfromGAC" are my machine specific, they'll be diff
on yours.

The situation now is that the ClassLibrary1.dll has been located by
ConsoleApplication1 (thanks to gac), but now the ClassLibrary1.dll cannot
locate its dependency which is ClassLibrary2.dll. So now if we just register
the ClassLibrary2.dll this error should also go away and execution of
ConsoleApplication1 should be smooth. So go ahead and register the
ClassLibrary2.dll (which u'll find inside the d2 folder) the same way you
did ClassLibrary1.dll. Once u r done registering the ClassLibrary2.dll with
the "Microsoft .NET Framework 1.1 Configuration", you can now run
ConsoleApplication1 and it'll give the following output:

value is dll2 value.

One of the files inside the zip file that you'll download is in "rar" format
and you can open it using the WinRar which you can get from
www.downloads.com.

I really hope that helps :-)

Ab.
http://joehacker.blogspot.com.
 
Abubakar,

That's a very thorough test!

However, there is one more consideration.

This has always worked for me in XP.

The problem is with w2k! (Which OS do you use ?)

When I get to work today, I will download and try this in w2k to see if I
can replication my/your results.

BTW -- I am seeing a lot of other .net/COM interop problems starting after
this weekend -- so I'm wondering if recent security patches have not caused
problems in general for w2k...

I put the 2nd dll in the \winnt\system32 directory.
this is another location where the search is done
And also, it would mean that a strongly named dll, registered in the
GAC, cannot be called by another dll.

I'd really like someone from Microsoft to prove me wrong on this, as I
suspect is a very major bug in the .NET assembly configuration
management(!)
ok so now i had to do an experiment, prepare a code and upload it for your
convenience. I'll give u a simple experiment to do now with assemblies
built by me.
Download the files from here
http://www.geocities.com/abubakar021/help.zip. Extract the files and
you'll find a folder named "runfromGAC". It has a ConsoleApplication1.exe
and 2 folders named d1 and d2. Check this: ConsoleApplication1.exe calls
dll1 which calls dll2. Now notice this that you only have
ConsoleApplication1.exe in the root folder and there is no dll there, so
ConsoleApplication1.exe does NOT know where its dependencies are located
which I'm going to demo you. Open a command prompt and browse to the dir
where your ConsoleApplication1.exe is and run it by typing
"ConsoleApplication1.exe" on the command prompt (without quotes of
course). You'll receieve the following error:

+++++++++++++++++++
Unhandled Exception: System.IO.FileNotFoundException: File or assembly
name ClassLibrary1, or one of its dependenci
es, was not found.
File name: "ClassLibrary1"
at ConsoleApplication1.Class1.Main(String[] args)

=== Pre-bind state information ===
LOG: DisplayName = ClassLibrary1, Version=1.0.1867.29218, Culture=neutral,
PublicKeyToken=59c3da0b75007a93
(Fully-specified)
LOG: Appbase = D:\tempcode\experiment\Run\runfromGAC\
LOG: Initial PrivatePath = NULL
Calling assembly : ConsoleApplication1, Version=1.0.1867.29219,
Culture=neutral, PublicKeyToken=null.
===

LOG: Application configuration file does not exist.
LOG: Publisher policy file is not found.
LOG: Host configuration file not found.
LOG: Using machine configuration file from
C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\config\machine.config.
LOG: Post-policy reference: ClassLibrary1, Version=1.0.1867.29218,
Culture=neutral, PublicKeyToken=59c3da0b75007a93

LOG: Attempting download of new URL
file:///D:/tempcode/experiment/Run/runfromGAC/ClassLibrary1.DLL.
LOG: Attempting download of new URL
file:///D:/tempcode/experiment/Run/runfromGAC/ClassLibrary1/ClassLibrary1.DL
L.
LOG: Attempting download of new URL
file:///D:/tempcode/experiment/Run/runfromGAC/ClassLibrary1.EXE.
LOG: Attempting download of new URL
file:///D:/tempcode/experiment/Run/runfromGAC/ClassLibrary1/ClassLibrary1.EX
E.
+++++++++++++++++++
NOTE: the paths before "runfromGAC" are my machine specific, they'll be
diff on yours.

Read the error, its clear that the class lib 1 is missing. If we register
it this error should go away right? So thats what we r going to do. Now
goto your Control Panel->Administrative Tools. Double click the "Microsoft
.NET Framework 1.1 Configuration". Right click the "Assembly Cache" node
and click "Add ...". Locate the dll1 from "d1" folder and click "Open" and
now the ClassLibrary1.dll is in gac. Now back to command prompt. run the
ConsoleApplication1.exe again. Now you see a similar error as before but
its not the same. Notice now its the following:
+++++++++++++++
Unhandled Exception: System.IO.FileNotFoundException: File or assembly
name ClassLibrary2, or one of its dependenci
es, was not found.
File name: "ClassLibrary2"
at ClassLibrary1.Class1.getCL2data()
at ConsoleApplication1.Class1.Main(String[] args)

=== Pre-bind state information ===
LOG: DisplayName = ClassLibrary2, Version=1.0.1867.29085, Culture=neutral,
PublicKeyToken=3727e4d9d6b9561c
(Fully-specified)
LOG: Appbase = D:\tempcode\experiment\Run\runfromGAC\
LOG: Initial PrivatePath = NULL
Calling assembly : ClassLibrary1, Version=1.0.1867.29218, Culture=neutral,
PublicKeyToken=59c3da0b75007a93.
===

LOG: Publisher policy file is not found.
LOG: Host configuration file not found.
LOG: Using machine configuration file from
C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\config\machine.config.
LOG: Post-policy reference: ClassLibrary2, Version=1.0.1867.29085,
Culture=neutral, PublicKeyToken=3727e4d9d6b9561c

LOG: Attempting download of new URL
file:///D:/tempcode/experiment/Run/runfromGAC/ClassLibrary2.DLL.
LOG: Attempting download of new URL
file:///D:/tempcode/experiment/Run/runfromGAC/ClassLibrary2/ClassLibrary2.DL
L.
LOG: Attempting download of new URL
file:///D:/tempcode/experiment/Run/runfromGAC/ClassLibrary2.EXE.
LOG: Attempting download of new URL
file:///D:/tempcode/experiment/Run/runfromGAC/ClassLibrary2/ClassLibrary2.EX
E.
+++++++++++++++
NOTE: the paths before "runfromGAC" are my machine specific, they'll be
diff on yours.

The situation now is that the ClassLibrary1.dll has been located by
ConsoleApplication1 (thanks to gac), but now the ClassLibrary1.dll cannot
locate its dependency which is ClassLibrary2.dll. So now if we just
register the ClassLibrary2.dll this error should also go away and
execution of ConsoleApplication1 should be smooth. So go ahead and
register the ClassLibrary2.dll (which u'll find inside the d2 folder) the
same way you did ClassLibrary1.dll. Once u r done registering the
ClassLibrary2.dll with the "Microsoft .NET Framework 1.1 Configuration",
you can now run ConsoleApplication1 and it'll give the following output:

value is dll2 value.

One of the files inside the zip file that you'll download is in "rar"
format and you can open it using the WinRar which you can get from
www.downloads.com.

I really hope that helps :-)

Ab.
http://joehacker.blogspot.com.


Ricola ! said:
Ok, I found a fix...I thought about it while riding my bicycle to
Tully's to get a coffee.

I put the 2nd dll in the \winnt\system32 directory.

So, for some reason, when a dll calls a 2nd dll.

My theory is that when a dll "runs", it's actually running in
\winnt\system32

And also, it would mean that a strongly named dll, registered in the
GAC, cannot be called by another dll.

I'd really like someone from Microsoft to prove me wrong on this, as I
suspect is a very major bug in the .NET assembly configuration
management(!)




--
Texeme Textcasting Technology
http://texeme.com

Indie Pop Rocks @ SomaFM
http://somafm.com/
 
Back
Top