Comments (8)
I cannot reproduce, I've been running and debugging an App on Android which does exactly this all day.
from mvvmcross.
I did test with 9.2.0-beta.3 and it also occurs in 9.2.0-beta.3.
Looking at the change history I narrowed it down to the changes made to the plugin code.
If I override InitializeApp in setup.cs to the following then the exception is not thrown:
protected override void InitializeApp(IMvxApplication app)
{
var pluginManager = InitializePluginFramework(Mvx.IoCProvider);
app.LoadPlugins(pluginManager);
base.InitializeApp(app);
}
My LoadPlugins Looks like this:
public override void LoadPlugins(IMvxPluginManager pluginManager)
{
base.LoadPlugins(pluginManager);
pluginManager.EnsurePluginLoaded<MvvmCross.Plugin.Messenger.Plugin>();
pluginManager.EnsurePluginLoaded<MvvmCross.Plugin.Visibility.Platforms.Android.Plugin>();
pluginManager.EnsurePluginLoaded<MvvmCross.Plugin.Color.Platforms.Android.Plugin>();
}
Commenting out the 3 calls to EnsurePluginLoaded even with the change to InitializeApp will cause the Exception to return.
from mvvmcross.
None of the plugins you are loading are necessary for bindings to work.
Are you overriding InitializeBindingBuilder
or CreateBindingBuilder
in your Setup.cs file by any chance?
from mvvmcross.
I am not overriding InitializeBindingBuilder
or CreateBindingBuilder
I did some more digging and was able to remove the calls to EnsurePluginLoaded for the Visibility and Color plugins.
So the following setup to not get the exception is:
protected override void InitializeApp(IMvxApplication app)
{
var pluginManager = InitializePluginFramework(Mvx.IoCProvider);
app.LoadPlugins(pluginManager);
base.InitializeApp(app);
}
public override void LoadPlugins(IMvxPluginManager pluginManager)
{
base.LoadPlugins(pluginManager);
pluginManager.EnsurePluginLoaded<MvvmCross.Plugin.Messenger.Plugin>();
}
My MainActivity's ViewModel does use dependency injected Services which use IMvxMessenger (injected into the service's constructor). With the recent change moving the plugin initialization after the call to initialize app could that be causing this issue? I would have expected an IOC resolve exception if that was the case.
from mvvmcross.
I cannot reproduce this at all, it would be helpful if you had a sample project where this is occuring.
One more question, do you have any plugins loading in your App
instance or just in Setup
?
from mvvmcross.
I am working on a sample project, however I think I may figured out the cause.
I am dependency injecting IMvxMessenger into the AppStart constructor. In the sample project I was working on, I get an IOC Resolve exception when I do this. This is a slightly different error then my original exception, however it does match my theory in the previous post.
In my original project, I have around 15 services injected in the AppStart Constructor. If I only inject
IMvxApplication, IMvxIoCProvider, IMvxNavigationService
and then resolve the other 12 in the ApplicationStartup override the exception is not thrown.
So it seems like with the recent changes IMvxMessenger can no longer be injected into the AppStart constructor?
from mvvmcross.
Yes, the order of loading has changed, due to preparation for a different IoC container, and removal of callbacks when certain things get registered in the container.
The Messenger plug-in doesn't need anything else to function, so it should work if registered earlier.
Let me check if maybe App start can be ordered differently too. I get that you want to be able to use dependencies in there to determine which VM to navigate to etc.
from mvvmcross.
So, I've been looking through MvxSetup to see if IMvxApplication
initialization can be done later in the process so you can rely on constructor injecting dependencies, but that hard to do, as many of the things we register at startup depend on it or IMvxViewModelLocatorCollection
it implements.
So I can only say that injecting dependencies in the ctor of IMvxApplication
can work with some dependencies, but not plugins etc. as they are registered later.
The best I can do is to call Initialize
after plugins have been loaded and and just before InitializeLastChance
so you can lazily load some dependencies in that method.
from mvvmcross.
Related Issues (20)
- MvvmCross.Plugin.Visibility not working in .NET 7.0 Android Project HOT 8
- It looks like mvx:Bi.nd in combination with InvertedVisibility is broken in 9.2 HOT 3
- Load order change results in not being able to use constructor injection for IMvxNativeVisibility in ValueCombiners
- MAUI App that uses existing MVVMCross ViewModels - Fails with mismatch in Dependencies for Android as Target HOT 7
- MvxRecyclerView crashes on .NET 8 HOT 3
- MvxModalPresentationControllerDelegate closes a ViewController when the ViewController is not actually dismissed by a user HOT 2
- Namespace "MvvmCross.Platforms.Console.Core" is missing in Nuget Package 9.2.0-beta.5 HOT 1
- Plugins not working on Android in 9.2.0-beta5 HOT 5
- Using Tibet binding on a iOS UILabel AttributedText property gives weird results in comparison to Fluent binding HOT 1
- MvxColorValueConverter not working on Android in 9.2.0 HOT 9
- mvvmcross is missing NuGet package README file HOT 1
- MvvmCross 9.2.0 beta has issues with .net 8.0.2 HOT 1
- [Bug]: MvxIosViewPresenter.cs should use .ConfigureAwait(true) _not false_ for virtual methods whose overrides might switch off the main thread HOT 9
- [Bug]: Clicked event not getting triggered since .NET 8 in combination with MvvmCross 9.2.0 HOT 2
- [Bug]: Failed to register an instance of MvxValueConverter with no default constructor HOT 1
- MvvmCross.Platforms.Ios namespace is missing in 9.2.0 & 9.2.0-beta HOT 2
- [CI]: SonarCloud does not report status on Pull Requests or detect branches
- [Bug]: [Android] `NavigateToFirstViewModel()` not called on Android when `SplashScreenActivity` is derived from `MvxActivity` HOT 20
- [Bug]: [Android] Execution never returns from `base.OnResume()` when `SplashScreenActivity` is derived from `MvxStartActivity` HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mvvmcross.