Re: Force Load DLL From Different Dir?

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



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.


.



Relevant Pages

  • Re: Complex Problem with AppDomains, Assembly Loading Contexts and COM Interop
    ... dynamically loaded into separate app domains in the context of an .Net ... extension running in a third party executable via COM Interop. ... to load such an assembly. ... Just sign and GAC your COM-visible assemblies. ...
    (microsoft.public.dotnet.framework.clr)
  • Re: Complex Problem with AppDomains, Assembly Loading Contexts and COM Interop
    ... ..Net assemblies get loaded by the CLR as the result of interop, ... and this allows us to load the assemblies into the Load context. ... default load context and in another is reachable only via the LoadFrom ... effectively executing LoadFrom? ...
    (microsoft.public.dotnet.framework.clr)
  • Re: Complex Problem with AppDomains, Assembly Loading Contexts and COM Interop
    ... I don't believe the basic problem is related to COM interop, ... default load context and in another is reachable only via the LoadFrom ... One workaround is to install all assemblies in the GAC but I personally ... The mechanism I used to avoid the Load versus LoadFrom problem was whenever ...
    (microsoft.public.dotnet.framework.clr)
  • Re: fuslogvw question
    ... Keep the result in LoadFrom context. ... Assembly is loaded in LoadFrom load context. ... All assemblies loaded during JIT compilation end up in this context. ... The second context is the "LoadFrom Context". ...
    (microsoft.public.dotnet.framework)
  • RE: some other problems
    ... I really think the best thing to do at this point is to open up a support ... assembly would fail to load in the Web Browser Control. ... caused by using the IP address when loading a web page into the Web Browser ... |>it that allows .Net assemblies to be loaded, ...
    (microsoft.public.dotnet.vjsharp)