all groups > dotnet clr > august 2003 >
You're in the

dotnet clr

group:

Properly referencing assemblies that reference other assemblies


Properly referencing assemblies that reference other assemblies Robert Myhill
8/27/2003 8:14:08 AM
dotnet clr: Say someone gives me AssemblyA.dll, which I install in my GAC. I then write
a new program, which does Assembly.Load(AssemblyA.dll), and compile my new
program to create MyApp.exe. So far so good.

Now, I don't know what, if any, assemblies AssemblyA.dll loads when it runs,
and this could cause some problems when MyApp.exe calls into AssemblyA.dll.
If AssemblyA.dll does

Assembly.LoadFrom("http:\\SomeonesServer\AnotherAssembly.dll");

then things should be OK, since the LoadFrom is referencing a globally
addressable dll.

But what if AssemblyA.dll does

Assembly.Load("ThisAssembly.dll");

then I need to have ThisAssembly.dll in my GAC, or else I need a codebase
element that points to a network location where ThisAssembly.dll lives.

Is this all correct? If so, it would be up to the publisher of
AssemblyA.dll to give me ThisAssembly.dll to put in my GAC, or tell me how
to update my codebase element to point to the network location of
ThisAssembly.dll.

Does this all sound right?

Thanks.

Robert

Re: Properly referencing assemblies that reference other assemblies Kumar Gaurav Khanna [.NET MVP]
8/29/2003 8:05:50 PM
Hi!

Assembly.Load actually invokes the Assembly resolver that attempts to
"determine" the correct assembly to be loaded. Consequently, "Load" takes
the assembly name, culture, version and public key. And since it uses all
this information, its expected that the assembly being attempted to be
loaded must be in the GAC.

Assembly.LoadFrom actually invokes the Assembly Loader, which Assembly.Load
internally invokes when it has determined the assembly to be loaded.
"LoadFrom" expects a fully qualified assembly name and nothing more. So the
assembly could be present anywhere.

Finally, if assembly A is loading certain other assemblies, which is
possible for its own internal usage, such assemblies would be designated as
the dependencies for Assembly A and its the responsibility of the Assembly A
developer to tell the clients of Assembly A about such dependencies and
distribute them, if applicable.

--

Regards,
Gaurav Khanna
----------------------------------------------------------------------------
----------------
Microsoft MVP - .NET, MCSE Windows 2000/NT4, MCP+I
WinToolZone - Spelunking Microsoft Technologies
http://www.wintoolzone.com/
[quoted text, click to view]

AddThis Social Bookmark Button