Skip to content

assemblymanager.cs: ResolveHandler finds assemblies based on StartsWith #533

@rmadsen-ks

Description

@rmadsen-ks

Environment

  • Pythonnet version: All
  • Python version: All
  • Operating System: All

Details

  • Describe what you were trying to get done.
    Loading an assembly called MyAssembly. Assembly did not exist, should have resulted in an error, but instead it loaded MyAssemblyTest.
    This can be done using Assembly.Load("AssemblyName").

Effectively this changes the way .NET normally loads assemblies and it ignores things such as strong naming. This could cause all kinds of unexpected effects in larger systems.

 static Assembly ResolveHandler(Object ob, ResolveEventArgs args){
            string name = args.Name.ToLower();
            for (int i = 0; i < assemblies.Count; i++) {
                Assembly a = (Assembly)assemblies[i];
                string full = a.FullName.ToLower();
                if (full.StartsWith(name)) { // this is a problem!
                    return a;
                }
            }
            return LoadAssemblyPath(args.Name);
        }

The FindAssembly method has obvious issues as well, but it only searches inside the python path, so the effect there is limited. The ResolveHandler searches through all currently loaded assemblies, which is a bigger problem.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy