-
Notifications
You must be signed in to change notification settings - Fork 224
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
.NET Core assembly loading might fail with FileNotFoundException #64
Comments
@mauroservienti is this a bug in both samples? |
The bug might affect all the .NET Core demos, so both The problem is the following: to keep the demo as simple as possible frontend projects directly reference ViewModel and UI Composition assemblies for the sole purpose of:
At sample startup time we scan the bin looking for ViewModel and UI Composition assemblies, in order to scan types we need to load the assembly, in .NET Core assemblies can load in 2 ways 😕 Assemblies can be referenced as compile time assemblies or as runtime assemblies, and to complicate things the way probing works depends on the deployment type
As it stands now samples work using the first approach. The problem I see is that users want to play at home and one of the thing they try is to remove the reference and create a sample deployment via some scripting...and kaboom, the assembly is not referenced anymore and we fall now in the second way of loading assemblies. The above sample code utilizes the To complicate things, Visual Studio 2017 post build events are broken when it comes to .NET Core projects. We could workaround it but I'd prefer to stay with references as of now. References: |
Removing myself from this since the fix is pending in #59, once that's merged this is done. |
@mauroservienti to clarify, does this bug currently exist in the |
It doesn't exist in the |
OK, so given that the fix also exists in the branch for #59, and therefore the new demo doesn't have the bug, the bug doesn't actually "exist" at all, so can we withdraw this? |
this will be automatically closed as we merge #59, is there any advantage in closing this before the PR is merged? Just wondering, it's not a problem at all to close this right now linking to the commit with the fix. |
Discussed with @mauroservienti and agreed to close, since the bug no longer exists in #59. |
When dynamically loading assemblies in .NET Core the full framework approach of using
Assembly.Load
might fail withFileNotFoundException
even if the file is available and in the expected location.Various reasons might lead to that error depending on the packaging configuration and/or if the assembly is already referenced.
The following snippet solves the issue by testing if the assembly is already referenced at compile time or run time (deployment package) and choosing the right approach to load the assembly.
The text was updated successfully, but these errors were encountered: