Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / CLR / August 2003

Tip: Looking for answers? Try searching our database.

Assembly.LoadFrom returns Assembly with "incorrect" Location and CodeBase

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Sean Winstead - 21 Aug 2003 19:30 GMT
When I load an assembly using
Assembly.LoadFrom("C:\temp\sumdumAssembly.dll"), the assembly is
loaded and its FullName property identifies it as the correct
assembly. However, the Location and CodeBase properties point to the
assembly that called Assembly.LoadFrom.

I have read the article titled "Application Isolation and
Assembly.LoadFrom" but it did not appear to address this issue.

Does anyone know why the aforementioned behavior occurs?

--
Sean Winstead
http://www.componentscience.net
Peter Allwin [MSFT] - 22 Aug 2003 02:11 GMT
Sean,

It sounds to me like the wrong assembly gets loaded. Assembly.LoadFrom does
not gurantee the assembly you load will be the same one you specified.
Basically it extracts the assembly info from the assembly you specified, and
it will return the assembly you specified only if it cannot find any
assembly with the same assembly info from high priority places (like the
GAC).

If you are using version 1.1 of the Framework (VS 2003) you can use
Assembly.LoadFile which circumvents this behavior.

Best Regards,

Peter Allwin

This posting is provided "AS IS" with no warranties, and confers no rights.

> When I load an assembly using
> Assembly.LoadFrom("C:\temp\sumdumAssembly.dll"), the assembly is
[quoted text clipped - 10 lines]
> Sean Winstead
> http://www.componentscience.net
Alan Shi [MSFT] - 22 Aug 2003 03:43 GMT
Actually, this is not quite true. LoadFrom will give you the assembly you
specify (even if it is found in the GAC, or other locations), however, you
cannot load two assemblies with the same identity via LoadFrom in the same
domain. For example, say 'myassembly' is a strongly-named assembly and I
deploy it to two locations, c:\first-location, and c:\second-location.
Assume your appbase is c:\appbase. Issuing:

Assembly.Load("c:\first-location\myassembly.dll")
Assembly.Load("c:\second-location\myassembly.dll")

...will cause myassembly to only be loaded from c:\first-location.

The behaviour you are referring to (e.g. if you LoadFrom an assembly, and
the same assembly, from the same location would have been found via
probing), only determines which load context the assembly gets put in.

As you mention, LoadFile is a potential workaround.

.\lan

Signature

This posting is provided "AS IS" with no warranties, and confers no rights.
http://blogs.gotdotnet.com/alanshi

> Sean,
>
[quoted text clipped - 28 lines]
> > Sean Winstead
> > http://www.componentscience.net
Peter Allwin [MSFT] - 22 Aug 2003 04:43 GMT
Thanks for clarifying :)

Signature

Best Regards,

Peter Allwin

This posting is provided "AS IS" with no warranties, and confers no rights.

> Actually, this is not quite true. LoadFrom will give you the assembly you
> specify (even if it is found in the GAC, or other locations), however, you
[quoted text clipped - 51 lines]
> > > Sean Winstead
> > > http://www.componentscience.net
Sean Winstead - 23 Aug 2003 03:49 GMT
>It sounds to me like the wrong assembly gets loaded. Assembly.LoadFrom does
>not gurantee the assembly you load will be the same one you specified.

Thanks to you and Alan for the information. I'm pretty sure it has the
correct assembly. I say this because once the assembly is loaded, the
code reflects through the assembly's types and it does find the
correct types. We have tested this on at least one clean machine and
the same behavior occurs.

My workaround was simple. The only reason I needed things like
Location and CodeBase is because I needed to get the loaded assembly's
AssemblyName. I was able to get the AssemblyName via another route.

--
Sean Winstead
http://www.componentscience.net

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.