In my application I was using the old SQLite-plugin.
Since MVVMCross 3.0.14 this version is deprecated and the Community.Sqlite plugin is advised.
The Community plugin was added via Nuget.
When trying to use the plugin without a bootstrapper, at runtime I get the error:
Failed to resolve parameter for parameter connectionFactory of type ISQLiteConnectionFactory when creating...
When trying to use the plugin with a bootstrapper, also at runtime, I get the error:
plugin not registered for type Cirrious.MvvmCross.Community.Plugins.Sqlite
How should this plugin be used?
-Edit-
This is my bootstrapper code:
using Cirrious.MvvmCross.Community.Plugins.Sqlite;
public class SqlitePluginBootstrap : MvxPluginBootstrapAction<PluginLoader>
{
}
Okay, Nuget added a reference to the portable library. I added a reference to the Sqlite.Touch library and then altered my bootstrapper:
using Cirrious.MvvmCross.Community.Plugins.Sqlite;
using Cirrious.MvvmCross.Community.Plugins.Sqlite.Touch;
public class SqlitePluginBootstrap : MvxLoaderPluginBootstrapAction<PluginLoader, Plugin>
{
}
This solved the "plugin not registered"-error for me.
Confirmed - I came across the same issue.
Nuget downloads the right things, but only adds the one reference, as Jacco points out.
It doesn't add the reference to Cirrious.MvvmCross.Community.Plugins.Sqlite.Touch.dll, and it doesn't put the bootstrap in for you automatically.
I have one extra using statement in my bootstrap for MvxLoaderPluginBootstrapAction. Here's the complete code:
using Cirrious.CrossCore.Plugins;
using Cirrious.MvvmCross.Community.Plugins.Sqlite;
using Cirrious.MvvmCross.Community.Plugins.Sqlite.Touch;
public class SqlitePluginBootstrap : MvxLoaderPluginBootstrapAction<PluginLoader, Plugin>
{
}
Related
I have an application using Glide 3.8.0 and I've just migrated it to 4.8.0. After migrating all the code to use the new Glide's API, I've found that my app launches this error when trying to load an image from the network:
java.lang.AbstractMethodError: abstract method "void com.bumptech.glide.module.RegistersComponents.registerComponents(android.content.Context, com.bumptech.glide.Glide, com.bumptech.glide.Registry)"
at com.bumptech.glide.Glide.initializeGlide(Glide.java:268)
at com.bumptech.glide.Glide.initializeGlide(Glide.java:221)
at com.bumptech.glide.Glide.checkAndInitializeGlide(Glide.java:182)
at com.bumptech.glide.Glide.get(Glide.java:166)
at com.bumptech.glide.Glide.getRetriever(Glide.java:680)
at com.bumptech.glide.Glide.with(Glide.java:732)
at com.fewlaps.android.quitnow.usecase.main.MainActivity.updateAvatar(MainActivity.java:356)
etc...
I've done the setup explained in the official documentation. As it requests, I wrote a class that extends AppGlideModule, it's annotated by #GlideModule, and it's empty. Empty? The official documentation says:
You’re not required to implement any of the methods in AppGlideModule for the API to be generated. You can leave the class blank as long as it extends AppGlideModule and is annotated with #GlideModule.
According to the Error's message, my issue is related with registerComponents() for sure, but I also tried to implement it with a blank implementation, and the issue remains.
As explained in AppGlideModule's JavaDoc (and as far as I know, only there...), if you are done with the migration from 3.x.x to 4.x.x, you have to implement isManifestParsingEnabled() returning false.
So, you'll end with a CustomAppGlideModule like this one:
#GlideModule
public class QNGlideModule extends AppGlideModule {
#Override
public boolean isManifestParsingEnabled() {
return false;
}
}
I'am currently following a tutorial of ASP.NET MVC in which instructor use auto mapper version 4.x and now i have only option of version 5.
When I create a mapping profile in which i get an error Mapper does not contain a definition for CreateMap:
I've attached all pictures of :
My Mapping Profile.
My Global.asax.cs.
/api/customer is working fine.
/api/movies is not working.
Is there something wrong i did or missed something?
Here's the link of my images
CreateMap is an instance method of the base class Profile
Just call
public MappingProfile()
{
CreateMap<A,B>() //...
}
How do you use the "GeoLocator" function in Xamarin Forms Labs. When i added the "GeoLocator" method in my class i kept getting the error that this.SetProperty does not exist. Anyone know how to use "GeoLocator"?
SetProperty is only available on the very latest pre release nuget package, and it's a method from our Base ViewModel...
You have to show your code to see what you are trying to do.
but it should be as simple as this:
var geolocator = DependencyService.Get<IGeolocator>();
var result = geolocator.GetPositionAsync(10000);
var strLatitude = result.Latitude.ToString("N4");
var strLongitude = result.Longitude.ToString("N4"),
In addition to Rui's answer, I would recommend using Plugins for Xamarin for this type of behavior. Specifically, the Geolocator Plugin for Xamarin and Windows.
Both of these geolocation codebases derived from Xamarin.Mobile, but as far as I can tell, the plugin is a bit more up-to-date, and supports Windows 10 (UWP) development as well.
If you post some of the code that you are using, it will be easier to help you out. But in the meantime, SetProperty does not exist because you are not inheriting from the Xamarin.Forms.Labs.Data.ObservableObject class. It contains the SetProperty method which is merely an implementation of INotifyPropertyChanged (changes the property if the value is different and raises the PropertyChanged event).
So you can either inherit from the XFormsLab's ObservableObject (or it's base view model class which inherits from ObservableObject, Xamarin.Forms.Labs.Mvvm.ViewModel) and then you will have access to SetProperty. Or you can not use SetProperty at all and use your own implementation of INotifyPropertyChanged
We took the code from this library and cleaned it up. You can clone the repo here:
https://github.com/MelbourneDeveloper/Adapt.Presentation.git
It is complete with samples for each platform. If you run the sample, you will see a tab for GeoLocator and it should run on all platforms. Android and UWP have been tested thoroughly.
The NuGet package Adapt.Presentation works to some extent but I've had difficulty getting it to work correctly on all platforms.
I am attempting to migrate from version 3.2.0 to 3.3.0. I am getting a compile error. I could not find an entry in the "Breaking Changes" section but here are my two errors in hope someone can guide me to a workable alternative.
public void RegisterTypeSingleton<T>(Type component, string name)
{
if (_container.Kernel.HasComponent(name))
_container.Kernel.RemoveComponent(name);
_container.Register(Component.For<T>().ImplementedBy(component).Named(name).LifeStyle.Singleton);
}
It seems Kernel.RemoveComponent() function has been depreciated. What has replaced this?
The second compiler error is at _container.Register(Component.For<T>().ImplementedBy(component).Named(name).LifeStyle.Singleton);
I am getting "The Type 'TService' must be a reference type in order to use it as a parameter.
I think you might be upgrading from an older version than 3.2.0. See below.
The removal of IKernel.RemoveComponent() is documented in the Breaking Changes document with v3.0.0. Here is the extract where Krzysztof explains why it was removed:
change - Removed the following methods:
GraphNode.RemoveDepender,
GraphNode.RemoveDependent,
IKernel.RemoveComponent,
IKernelEvents.ComponentUnregistered,
INamingSubSystem.this[Type service],
INamingSubSystem.GetHandler,
INamingSubSystem.GetService2Handler,
INamingSubSystem.GetKey2Handler,
INamingSubSystem.UnRegister(String key),
INamingSubSystem.UnRegister(Type service)
Also INamingSubSystem.Register now takes only IHandler as its argument
impact - low
fixability - none
description - The methods were implementation of "remove component from the container" feature
which was flawed and problematic, hecen was scraped.
fix - Working around is quite dependant on your specific usage. Try utilizing IHandlerSelectors.
For changed Register method, just update your calling code not to pass the name.
handler.ComponentModel.Name is now used as the key, as it was happening in all places so far
anyway, so this change should have no real impact.
RegisterComponent() won't overwrite an existing service registration, it'll just register another component for the same service, unless you specify the same name where it'll throw an exception informing you there is another component registered with that name. If your application doesn't replace components very often you could use the IsDefault() method on the registration to get Windsor to resolve the new component by default, just note the other component is still registered.
If your application replaces components often and you don't want the other registrations left there, you'd be best using a custom IHandlerSelector or ISubDependencyResolver so Windsor will ask you each time what component you want used for a specific service.
Also in v3.0.0 a change was made to ensure that value types cannot be passed to the registration methods. You'll need to add a generic constraint to your method that accepts a generic parameter so that it also only accepts reference types:
public void RegisterTypeSingleton<T>(Type component, string name)
where T : class
{
...
}
I have a trivially small PHPUnit test that looks like this:
<?php
namespace VNN\PressboxBundle\Tests\Entity;
namespace VNN\PressboxBundle\Entity;
use VNN\PressboxBundle\Entity\User;
use Symfony\Bundle\FrameworkBundle\Test\WebTestCase;
use Phactory\Sql\Phactory;
class UserTest extends EntityTest
{
public function testCreate()
{
Phactory::reset();
}
}
When I try to run it, I get this:
There was 1 error:
1) VNN\PressboxBundle\Entity\UserTest::testCreate
ErrorException: Runtime Notice: Non-static method Phactory\Sql\Phactory::reset() should not be called statically, assuming $this from incompatible context in /Users/jason/Web/pressbox/src/VNN/PressboxBundle/Tests/Entity/UserTest.php line 13
What's up with that? All the docs call it statically.
I'm doing this on Symfony 2.0, if that makes a difference.
The documentation says you should be using the top-level Phactory class directly under lib/--not the individual implementations such as Phactory/Sql/Phactory which get instantiated based on the PDO object you pass to setConnection. Change
use Phactory\Sql\Phactory;
to
require_once 'Phactory/lib/Phactory.php';
The main class is in the global namespace and doesn't require a use statement.
https://github.com/chriskite/phactory/issues/30
From the code, setConnection, define and create are not static functions but the README and website guide do not reflect that.
e.g. test code
https://github.com/chriskite/phactory/blob/next/tests/Phactory/Sql/PhactoryTest.php
use Phactory\Sql\Phactory;
...
$this->pdo = new \PDO("sqlite:test.db");
$this->phactory = new Phactory($this->pdo);
$this->phactory->define('user');
$this->phactory->reset();
I don't know when it has been changed.
Too late anyways...
The current version, 0.3.2, is not backward compatible with the static method structure that is documented.
Here is the breaking commit: https://github.com/chriskite/phactory/commit/d3b60eeedea955ab7b5803ec29446d19888d3849
Unfortunately, the documentation has not been updated on http://phactory.org and the pearhub repo is no longer available.
I would look to the tests for examples: https://github.com/chriskite/phactory/blob/next/tests/Phactory/Sql/PhactoryTest.php