Re: Force Load DLL From Different Dir?
- From: jiewan@xxxxxxxxxxxxxxxxxxxx ("Jie Wang [MSFT]")
- Date: Tue, 12 May 2009 09:24:05 GMT
Hi Pavel,
Which means even you load the new version of MyCommon at the first hand,
when MyAddIn trying to resolve its reference to MyCommon, CLR will still
try load the version MyAddIn bound to at compile time.
Last time I identified the behavior, but I failed to explain why.
So let me clarify it.
Actually this is NOT version related, but context related: Assemblies can
be loaded into one of three contexts, or can be loaded without context.
The load context contains assemblies found by probing: in the GAC, in a
host assembly store if the runtime is hosted, or in the ApplicationBase and
PrivateBinPath of the application domain. Most overloads of the Load method
load assemblies into this context.
The load-from context contains assemblies for which the user provided a
path not included in the directories searched by probing. LoadFrom,
CreateInstanceFrom, and ExecuteAssembly are examples of methods that load
by path.
The reflection-only context is not our concern here.
The load-from context allows an assembly to be loaded from a path not
included in probing, and yet allows dependencies on that path to be found
and loaded because the path information is maintained by the context.
If an assembly is loaded with LoadFrom, and the probing path includes an
assembly with the same identity but a different location, an
InvalidCastException, MissingMethodException, or other unexpected behavior
can occur.
The LoadFrom method for your reference:
http://msdn.microsoft.com/en-us/library/1009fa28.aspx
I think that's why the LoadFrom approach should be avoided.
So we still need to copy the new MyCommon.dll to the application's
ApplicationBase or PrivateBinPath, to replace the old version.
Regards,
Jie Wang (jiewan@xxxxxxxxxxxxxxxxxxxx, remove 'online.')
Microsoft Online Community Support
Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we can improve the support we provide to you. Please
feel free to let my manager know what you think of the level of service
provided. You can send feedback directly to my manager at:
msdnmg@xxxxxxxxxxxxxx
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/en-us/subscriptions/aa948868.aspx#notifications.
Note: MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 2 business days is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions. Issues of this
nature are best handled working with a dedicated Microsoft Support Engineer
by contacting Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/en-us/subscriptions/aa948874.aspx
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
.
- References:
- Force Load DLL From Different Dir?
- From: SnapDive
- RE: Force Load DLL From Different Dir?
- From: "Jie Wang [MSFT]"
- Re: Force Load DLL From Different Dir?
- From: Pavel Minaev
- Force Load DLL From Different Dir?
- Prev by Date: Re: GCHandle.Alloc
- Next by Date: Re: Force Load DLL From Different Dir?
- Previous by thread: Re: Force Load DLL From Different Dir?
- Next by thread: Re: Force Load DLL From Different Dir?
- Index(es):
Relevant Pages
|