-
Notifications
You must be signed in to change notification settings - Fork 1k
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
EnableDynamicLoading causes multiple loading of assemblies at runtime #41805
Comments
I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label. |
I couldn't figure out the best area label to add to this issue. If you have write-permissions please help me learn by adding exactly one area label. |
In the repro, this is expected.
Are there other .NET components that get loaded by the process? Perhaps something that does depend on the ASP.NET runtime? Using the Is the MissingMethodException coming from a call your library makes? Do you also see
If you are expecting those dependencies to be coming from a shared place (such that your library should not carry them with it), setting <PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="8.0.0">
<Private>false</Private>
<ExcludeAssets>runtime</ExcludeAssets>
</PackageReference> |
If you don't actually want your library loaded into a separate ALC, we have an API in .NET 8+ that allows loading a component into the default ALC (and then calling a function on it). That would make it so that the library lives in the default ALC, so dependencies like |
Describe the bug
Compile time
When adding
<EnableDynamicLoading>true</EnableDynamicLoading>
a copy ofMicrosoft.Extensions.DependencyInjection.Abstractions.dll
is included in the output directory.Runtime
At runtime (loading using the process described here) the assembly
<output_directory>/Microsoft.Extensions.DependencyInjection.Abstractions.dll
is loaded first and later another version ofMicrosoft.Extensions.DependencyInjection.Abstractions.dll
is loaded from the dotnet installation directory. Then when trying to call the methodBuildServiceProvider
this exception is thrown:Maybe this bug is related
List of Assemblies
These assemblies show this behaviour:
Microsoft.Extensions.DependencyInjection.Abstractions.dll
Microsoft.Extensions.Logging.Abstractions.dll
To Reproduce
dotnet build
Microsoft.Extensions.DependencyInjection.Abstractions.dll
is included in the output directory (usually<project_dir>/bin/Debug/net8.0
)Further technical details
Output of
dotnet --info
:Workaround
Add this to your
.csproj
file to delete the assemblies from the output directory:The text was updated successfully, but these errors were encountered: