Skip to content

[WinUI3.0 Desktop(App and ClassLibrary)] A UserControl in a ClassLibrary can't be dynamically loaded by a custom AssemblyLoadContext class #3888

Closed

Description

I create several projects and the relations are as following:
structure

In short, I want to use WinUI 3.0 Desktop App to dynamically load a ClassLibrary named HelloPlugin.dll.

  • Both App and HelloPlugin.dll add reference to an interface "ICommand" in PluginBase.dll
  • HelloPlugin.dll implements the "ICommand" interface which includes a field of UserControl.
  • HelloPlugin.dll add reference to another ClassLibrary named DataProvider.dll
  • I implement a custom AssemblyLoadContext in App to dynamically load HelloPlugin.dll and code snippets is as following
    code

[Bug]
I can successfully load HelloPlugin.dll in App and activate as ICommand and some fields leveraging DataProvider.dll are also loaded successfully.
However, when I invoke to get that UserControl field, it crashes at UserControl's constructor show as followings
error1
error2

Can you help to see if I miss anything in order to load resource of UserControl?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions