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/