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

Problems with the display of pages from a dynamically loaded assemblyBug title #6920

Closed
1 of 2 tasks
amazatis opened this issue Apr 1, 2022 · 2 comments
Closed
1 of 2 tasks
Labels
product-winui3 WinUI 3 issues

Comments

@amazatis
Copy link

amazatis commented Apr 1, 2022

Describe the bug

I am writing an app in WinUi with which it should be possible to reload plug-ins. The problem is that when I instantiate a page in my dynamically called method from a reloaded assembly and return it, it crashed. If I use a standard page, it is displayed successfully. I do not understand the difference. In the example the TestPage is also of type Page (WinUI Page).

--- MainWindow.xaml.cs
assembly = Assembly.LoadFile(dir);
var types = assembly.GetTypes();
string classname = module.Namespace + "." + module.Classname;
type = assembly.GetType(classname);
method = type.GetMethod("ShowModule", objectTypes);
classInstance = Activator.CreateInstance(type);
mResult = (ModuleResult)method.Invoke(classInstance, param);
this.ContentHost.Children.Add(mResult.Page);

--- Module assembly
public override ModuleResult ShowModule(ModuleParameters iModulParameters)
{
TestPage module = new TestPage(); // --- It crashed => this ist a empty Page
moduleResult.Content = module;

//Page module = new Page(); // --- works successfully
//moduleResult.Content = module;

return moduleResult;
}

Steps to reproduce the bug

--- MainWindow.xaml.cs
assembly = Assembly.LoadFile(dir);
var types = assembly.GetTypes();
string classname = module.Namespace + "." + module.Classname;
type = assembly.GetType(classname);
method = type.GetMethod("ShowModule", objectTypes);
classInstance = Activator.CreateInstance(type);
mResult = (ModuleResult)method.Invoke(classInstance, param);
this.ContentHost.Children.Add(mResult.Page);

--- Module assembly
public override ModuleResult ShowModule(ModuleParameters iModulParameters)
{
TestPage module = new TestPage(); // --- It crashed => this ist a empty Page
moduleResult.Content = module;

//Page module = new Page(); // --- works successfully
//moduleResult.Content = module;

return moduleResult;
}

Expected behavior

No response

Screenshots

188150-screenshot-2022-03-30-074759

NuGet package version

WinUI 3 - Windows App SDK 1.0

Windows app type

  • UWP
  • Win32

Device form factor

Desktop

Windows version

Windows 11 (21H2): Build 22000

Additional context

No response

@ghost ghost added the needs-triage Issue needs to be triaged by the area owners label Apr 1, 2022
@ojhad ojhad added product-winui3 WinUI 3 issues and removed needs-triage Issue needs to be triaged by the area owners labels Apr 7, 2022
@ojhad
Copy link
Contributor

ojhad commented Apr 7, 2022

@Scottj1s Is this a supported scenario for CSWinRT?

@amazatis
Copy link
Author

I hope so. I need this possibility in WinUI for applications to be able to insert plug-ins. This technique has worked under WPF, UWP.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
product-winui3 WinUI 3 issues
Projects
None yet
Development

No branches or pull requests

2 participants