Description
Describe the bug 🐞
In a WinUI 3 app project that has a dependency on the ReactiveUI.WinUI nuget package, if you add the IActivatableViewModel
interface to a view model and implement the interface, then in the Constructor for that view model set up the WhenActivated Linq method in the constructor. When the Constructor is loaded, ReactiveUI raises an error of
"Could not load file or assembly 'ReactiveUI.XamForms, Version=19.6.0.0, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified."
This is a bug, the XamForms assembly can not be referenced in a WinUI project, nor should it be needed
Step to reproduce
-
Add A Class and cal it MainPageViewModel
-
on the main page add a Dependency property to the newly created MainPageViewModel
-
In the MainPage constructor, initialize the dependency property to a new instance of MainPageViewModel
-
Add ReactiveUI.WinUI nuget dependency to the project
-
Run the project, it runs fine
-
Stop Project.
-
Add the
IActivatableViewModel
interface to MainPageViewModel and implement it. -
Modify the constructor for the
MainPageViewModel
to be like so
public MainPageViewModel()
{
Activator = new ViewModelActivator();
( this ).WhenActivated(disposables =>
{
// Use WhenActivated to execute logic
// when the view model gets activated.
// do nothing, this is just to cause the bug
// HandleActivation(disposables);
});
}
- Run it, and you will break on the line
( this ).WhenActivated(disposables =>
with the error of
System.IO.FileNotFoundException
HResult=0x80070002
Message=Could not load file or assembly 'ReactiveUI.XamForms, Version=19.6.0.0, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified.
Source=
StackTrace:
If you put a breakpoint i
Reproduction repository
https://github.com/xsgeek/ReactiveUI-WinUI-Bug
Expected behavior
The WinUI project should run just fine with just a reference to the ReactiveUI.WinUI assembly.
Screenshots 🖼️
No response
IDE
Visual Studio 2022
Operating system
Windows 11
Version
net7.0-windows10.0.22621.0
Device
Windows
ReactiveUI Version
19.6.1
Additional information ℹ️
No response