Skip to content

AssemblyManager.GetAssemblyByFile might have a bug #21

Open
@chucklu

Description

https://github.com/s-siplivy/PackageChecker/blob/master/PackageChecker/PackageChecker/Files/AssemblyManager.cs#L15
Today I encounter a problem, this tool could not recognize the assembly version of physical file.
A.dll depends on B.dll, and both of them locate on same bin folder of a mvc site.
A.dll requires B.dll with version 1.1.1, and the assembly version of B is correct(1.1.1) under bin folder.
However this tool gives info, that A.dll requires B.dll with another version 1.1.0.
It seems, A.dll is not correct loaded.

I replace the method content with

	internal static Assembly GetAssemblyByFile(string fileName)
        {
            var assembly = Assembly.ReflectionOnlyLoadFrom(fileName);
            if (assembly == null)
            {
                throw new FileNotFoundException(fileName);
            }

            return assembly;
        }

https://stackoverflow.com/questions/49283983/getting-wrong-version-from-assembly-using-reflection
There are lots of load related methods under Assembly https://docs.microsoft.com/en-us/dotnet/api/system.reflection.assembly.createinstance?view=net-5.0
Not sure which is the most correct one to use

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions