Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AssemblyManager.GetAssemblyByFile might have a bug #21

Open
chucklu opened this issue Jan 14, 2021 · 1 comment
Open

AssemblyManager.GetAssemblyByFile might have a bug #21

chucklu opened this issue Jan 14, 2021 · 1 comment

Comments

@chucklu
Copy link

chucklu commented Jan 14, 2021

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

@chucklu
Copy link
Author

chucklu commented Jan 14, 2021

And the weird thing is, after I run with new tool. Check the dependency correctly.
Then open the old tool again, the problem disappear.
Not sure what happened, do you have any idea about this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant