Skip to content

plugins fail to load for dotnet 6 single file - self contained app #59961

Closed
@freddyrios

Description

@freddyrios

Description

Running plugins with dotnet 6 rc1 for single file, self contained applications broke. The issue was found originally in Linux, but was also reproduced on windows. Specifically the AssemblyDependencyResolver's constructor throws an exception when loading the plugin.

To reproduce follow the instructions on the readme in this isolated reproduction of the issue: https://github.com/freddyrios/pluginsloadfailure.

Alternatively follow microsoft documentation on creating an application with plugins https://docs.microsoft.com/en-us/dotnet/core/tutorials/creating-app-with-plugin-support and publish it as a single file, self contained app with the runtime identifier that matches your system.

Configuration

dotnet --version: 6.0.100-rc.1.21463.6
reproduced both on windows 10 and raspbian (linux / debian)
windows 10 was x64 and raspbian is arm
doesn't look specific to the OS or architecture

Regression?

It is a regression, see the demo which shows doing the same steps with a different target breaks.

Other information

This is the stacktrace:

System.InvalidOperationException: Cannot load hostpolicy library. AssemblyDependencyResolver is currently only supported if the runtime is hosted through hostpolicy library.
---> System.EntryPointNotFoundException: Entry point was not found.
at Interop.HostPolicy.corehost_set_error_writer(IntPtr errorWriter)
at System.Runtime.Loader.AssemblyDependencyResolver..ctor(String componentAssemblyPath)
--- End of inner exception stack trace ---
at System.Runtime.Loader.AssemblyDependencyResolver..ctor(String componeyntAssemblyPath)
at AppWithPlugin.PluginLoadContext..ctor(String pluginPath) in [redacted]\pluginsloadfailure\AppWithPlugin\PluginLoadContext.cs:line 13
at AppWithPlugin.Program.LoadPlugin(String relativePath) in [redacted]\pluginsloadfailure\AppWithPlugin\Program.cs:line 71
at AppWithPlugin.Program.<>c.

b__0_0(String pluginPath) in [redacted]\pluginsloadfailure\AppWithPlugin\Program.cs:line 29
at System.Linq.Enumerable.SelectManySingleSelectorIterator`2.ToList()
at AppWithPlugin.Program.Main(String[] args) in [redacted]\pluginsloadfailure\AppWithPlugin\Program.cs:line 16

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions