Skip to content
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

Loading assemblies from .deps.json file #294

Open
gw-ubunye opened this issue Sep 16, 2024 · 0 comments
Open

Loading assemblies from .deps.json file #294

gw-ubunye opened this issue Sep 16, 2024 · 0 comments
Labels
question Further information is requested

Comments

@gw-ubunye
Copy link

I have a situation where assemblies that are only referenced in a .xaml file are not loaded into the ALC. As an example, I use the WPFLocalizeExtension library and I use in my XAML code only. The file is listed in the .deps.json file of the project, but when I try to show the window that references the library, I get the following exception:

System.Windows.Markup.XamlParseException: 'Could not load file or assembly 'WPFLocalizeExtension, Culture=neutral, PublicKeyToken=c726e0262981a1eb'. The system cannot find the file specified.'

There are 2 ways of solving this that I have found so far, neither of which are particularly appealing to me:

  1. Load the assembly explicitly - and all its dependencies - in the code behind of the control.
  2. Create a dummy instance of a type in the missing assembly, e.g. _ = LocalizeDictionary.Instance;

In #61 @natemcmaster makes this statement:

_PluginLoader already uses the .deps.json file (if present) at runtime to prepopulate a list of assemblies that can be loaded. This file is read automatically if it is present next to your plugin executable on disk...which it typically is. _ (emphasis mine).

The problem is, how would I know which dependencies are available? There is no property on the PluginLoaded class that gives me that.
The loader sits in the host application, and it only knows about predefined the contract(s), so you'd have to be able to enumerate all the assemblies that were discovered by the loader of a specific plugin and then load them all. This is the brute-force way.

I would ask those with more experience/knowledge than me; what is the correct/best approach to deal with this?

@gw-ubunye gw-ubunye added the question Further information is requested label Sep 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

1 participant