Problems with the display of pages from a dynamically loaded assemblyBug title #6920
Closed
1 of 2 tasks
Labels
product-winui3
WinUI 3 issues
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
NuGet package version
WinUI 3 - Windows App SDK 1.0
Windows app type
Device form factor
Desktop
Windows version
Windows 11 (21H2): Build 22000
Additional context
No response
The text was updated successfully, but these errors were encountered: