-
Notifications
You must be signed in to change notification settings - Fork 1
You must call EnsureLoaded on the File plugin before using the DownloadCache #119
Comments
Have you tried deleting the bootstrap files and adding them again? |
Deleting the bootstrap files and adding the packages back via NuGet didn't change anything. The Droid project has the following plugins:
How does MvvmCross ensure the plugins are loaded in the correct order when one plugin depends on another plugin? |
I have run into the same problem, however I didn't delete the
|
I faced the same issue too, thanks for the fix Zolee |
I'm on iOS, and MvvmCross 4.2.2. Putting in just Zolee's workaround doesn't work, I got the following exception:
In addition to Zolee's workaround, I need to do the following:
|
Just ran into the same issue, @Zolee007 's fix helped. |
Now that I also started to develop the iOS side of my application, I also run into the problem as @alfredp77 . I looked into the source code a bit to try to figure out the difference between the Android and iOS plugin loading. I found that
By doing this in addition of my previously posted workaround makes iOS working as well. |
@alfredp77 @Zolee007 I get this on iOS now... On a project it worked, on the current one I get this: System.ArgumentException: Cannot create an instance of UpWorky.Mobile.iOS.Employee.NoPreLoadPluginBootstrapAction`2[TPlugin,TPlatformPlugin] because Type.ContainsGenericParameters is true. Do you have some suggestions? Thanks |
I tried @Zolee007 's solution and had same problem that @alfredp77 had. As opposed to the latter workaround, I just went back and used the old manual registration in Setup.cs which has changed slightly from previous versions. I also removed the Bootstrap files for now until this get's sorted out. This works fine for 4.2.2.
|
I will check in a few hours. Thanks |
I ran into the same issue as @alfredp77, and @Zolee007's first workaround fixed it for me on Android. Once I started on iOS, @Zolee007 's workaround to add this into the Setup.cs worked great!
I didn't have to remove any of the original Bootstrap files or manually register the plugin loaders. |
@SeeD-Seifer any idea what is going on? I haven't debugged this yet, but seems like the MvxPluginManager does not pick up some plugins. |
OK. So I've been debugging a bit. The problem seems to be that the So if I remove the boostrap files for File and DownloadCache and make a new where both are defined in this order:
It seems to work fine. If I swap the order in the file to:
💥 everything blows up... How this worked before I have no idea, maybe by coincidence? I've reviewed the changes @SeeD-Seifer made to the plugins registry in MvvmCross/MvvmCross@ffd2b33 and I don't see how it would change anything. Now! On the other side this 4e8ea9f has added more stuff to the plugin loader, which matches the crash I get |
@Cheesebaron I'll review the thread and the code later today and let you know when find the reason of the issue. Highly suspect this is somehow related to my changes. |
@SeeD-Seifer I am not sure it is actually your changes that did it. However, rather @promontis' changes which explicitly ask for the File plugin. I think we need to do something about discovering dependencies in Plugins and fix load order. |
@Cheesebaron you was right, @promontis commit broke the plugin loading. Apart from direct fix I have noticed few things:
|
Ah yes, the commit I did eager loads the File plugin, which it shouldn't do. The fix from @SeeD-Seifer fixes that, awesome! I agree that the dependencies between plugins, the loading of them, and the order in which they load should be fixed. Already bumped my head several times because of it. I did talk to @martijn00 at the last mvvmcross meetup we had about this... maybe he can jump into this conversation? I thought the solution he proposed was to actually remove the bootstrap loaders and initialize the plugins yourself in the correct order. |
@promontis Yes, to manually register the plugins could be a temporary solution. I would like to look into how we can make a proper fix in combination with moving the plugins to Net Standard (PCL) based setup. @Cheesebaron already looked into this a bit in #63 (comment) |
To ensure plugins loaded in the same order MvxBootstrapRunner should be updated. public virtual void Run(Assembly assembly)
{
// types order is not determined.
var types = assembly.CreatableTypes()
.Inherits<IMvxBootstrapAction>();
foreach (var type in types)
{
this.Run(type);
}
} Simple solution is to always sort types by Name or FullName. |
That would solve it? F comes after D? |
Haha... that's what I first did as well :) sorting the plugins by name. Now I just manually register the plugins, so that I minimize the performance hit of using reflection. |
@Cheesebaron when I launched MvvmCross-Samples/WorkingWithCollection project which uses File and DownloadCache plugins I was surprised, it didn't crash with MvvmCross 4.2.3 NuGet packages. It appeared, for some reason MvxBootstrapRunner loaded File plugin first, just because Hacking MvxBootstrapRunner to sort types lead to stable reproduce of the issue. Can't explain why. |
Hy Guys, this is a bit confusing...can somebody put a gist with the whole correct steps? I am using the Support JASlider also. Maybe this adds some problems as well. `
In the Setup class I have
Should the download cache plugin bootStrapper look like this?
I have upgraded the Collections sample to 4.2.3 and it works but in our project it does not work... This is very strange. |
This is fixed in 4.3.0 |
Thank you very much. |
@Cheesebaron I have same issue on 4.4.0 (In release mode -> Linking All assemblies)
|
So This issue is about order of plugins being loaded. Not linking issues. |
Yes MvxFilePluginManager is linked away and with this method overriding i have solved it |
The update from 4.2.0 to 4.2.1 seems to sometimes cause issues if the project uses the DownloadCache and File plugins. When this happens an exception is thrown during setup
During the update NuGet shows an error claiming the various
Bootstrap
files can not be found. The files are present and have not been modified from the originals. It's not clear to me why NuGet can't see these files.I've asked about this on Stackoverflow.
It seems like the DownloadCache plugin has a dependency on the File plugin but the DownloadCache is loaded before the File plugin has been loaded.
One workaround is to manually remove the DownloadCache and File bootstrap loaders, then manually call EnsureLoaded on the plugins in the correct order:
Steps to reproduce
Expected behavior
The plugins should load automatically in the correct order.
Actual behavior
An exception is thrown during setup.
Configuration
Version: 4.2.1
Platform: Android
The text was updated successfully, but these errors were encountered: