Repository navigation
Closed
Labels
kind/bugSomething isn't working
Description
Steps to reproduce:
- Clone this repository, restore nuget packages, rebuild.
- Run UnoTest.Web project (right click, start new instance) - clicking the button will increase the counter - OK.
- Change MainPage.xaml by adding DataContext attribute to the header:
<Page x:Class="UnoTest.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:UnoTest"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
mc:Ignorable="d"
DataContext="{Binding MainPageViewModelInstance, Source={StaticResource Locator}}">
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
...
</Page>
- In MainPage.xaml.cs remove (or comment) line creating a new instance of the MainPageViewModel class:
public sealed partial class MainPage : Page
{
public MainPage()
{
InitializeComponent();
// DataContext = new MainPageViewModel();
}
}
- Rebuild the whole solution.
Result:
6. Run UnoTest.UWP project (right click, start new instance) - clicking the button will increase the counter - correct behavior after change.
7. Run UnoTest.Web project (right click, start new instance) - clicking the button will not increase the counter - bad behavior after change.
Expected result:
After running UnoTest.Web app, clicking the button should increase the counter.
Metadata
Metadata
Assignees
Labels
kind/bugSomething isn't working


Activity
jeromelaban commentedon Jun 16, 2018
This is a known issue for WASM, this works for iOS and Android.
The best workaround for now is to declare it in a merged resource dictionary.
[-]Wasm - static resources declared in App.xaml doesn't work.[/-][+]Static resources declared in App.xaml are not applied[/+]carldebilly commentedon Jun 19, 2019
I reproduced the problem and I found the cause... it's very far from the reported bug.
The actual cause
The Wasm version of MvvmLight will use the netstandard1.0 version of the package and the IoC in this version won't implement the
IServiceLocator.See those lines: https://github.com/nventive/uno.mvvmlight/blob/3408287579ace291c9519edefc8017df6a151aac/GalaSoft.MvvmLight/GalaSoft.MvvmLight.Extras%20(PCL)/Ioc/ISimpleIoc.cs#L38-L40
Since the project
Uno.Coreis compiled in netstandard2.0, it will include his own version ofCommonServiceLocator(v1.3) as defined in this bug I just opened: unoplatform/Uno.Core#53What is happening in the app
The initial navigation to
MainPage.xamlwill be initiatedIn the
MainPage.xamlInitializeComponent(), Uno will successfully resolve theLocatorresourceUno will call the
MainPageViewModelInstanceproperty ofViewModelLocatorThis one will cast
SimpleIoc.Default as IServiceLocator, which is not implemented this wayCode here: https://github.com/zbigniew-gajewski/uno-wasm-aspnet-core/blob/78e9491427166d4a4242ddbec85e7080c38f51e9/UnoTest/UnoTest.Shared/ViewModels/ViewModelLocator.cs#L24
A null-reference exception will terminate the initial navigation, leading to the false interpretation there's a problem with resources.
I will close this bug as not related to Uno directly (the real issue has been created in
Uno.Coreproject). Feel free to reopen it or ask more details.carldebilly commentedon Jun 19, 2019
Ooohhh... by the way, to find this problem I found those 2 assemblies must be removed from linker in the
LinkerConfig.xml:zbigniew-gajewski commentedon Jun 19, 2019
<assembly fullname="UnoTest.Wasm" />accessing data with BreezeSharp doesn't work, I mean, the list with received data is not displayed.carldebilly commentedon Jun 19, 2019
When I said removed from linker, it means those lines must be added to the config file ;-)
Sorry for the confusion.
zbigniew-gajewski commentedon Jun 19, 2019
Aaa, OK :) Thanks.
Merge pull request unoplatform#47 from unoplatform/dev/jela/rc-mu-ups…
Merge pull request unoplatform#47 from unoplatform/android-work
chore: MOAR LOGGING
chore: MOAR LOGGING