Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

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

Copy link
Copy link
@rmadsen-ks

Description

@rmadsen-ks
Issue body actions

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

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.