-
Notifications
You must be signed in to change notification settings - Fork 456
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
Error when loading external assemblies #619
Comments
Hey @sirosimo, sounds like a variant of dotnet/runtime#13511 - it appears to be a .Net Core issue rather than .Net 6 specifically from some brief Linqpad testing. There might be some work to be done around
For the .net standard build (which your .net 6 target will be using), |
-- Edited out my wrong code :) -- There might be a similar issue with the method |
Working on an app migration form .Net Framework 4.8 to .Net 6, I'm facing an issue when trying to registered external assemblies from a certain folder.
Here is an example project that highlight the issue: https://github.com/sirosimo/CastleSandBox.git
The external assemblies and classes implementing IPersonBase aren't referenced in the main application and may be in a different namespace.
In the framework version, this code work good, but when switching to .Net 6, I encounter FileNotFoundException when trying to load the assemblies.
Probable Cause:
I think I tracked down the issue to [Core.Internal.ReflectionUtil.cs line 136] (https://github.com/castleproject/Windsor/blob/master/src/Castle.Windsor/Core/Internal/ReflectionUtil.cs#:~:text=var%20assembly%20%3D%20LoadAssembly(assemblyName)%3B) and more precisely System.Reflection.Assembly
The assembly is loaded using the assembly name as opposed to the assembly file path. When using only the assembly name (Assembly.Load(assemblyName)) it results with a FileNotFoundException as the assembly name isn't referenced in the main application
Possible Solution:
Add an extra method to ReflectionUtil, using LoadFrom() instead of Load():
And change the way the assembly are being loaded to always refer to the filePath if available:
I tested it and it pass all the Castle.Windsor.Test
Thank you
Castle.Windsor 5.1.2
Castle.Core 4.1.1
The text was updated successfully, but these errors were encountered: