Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 77050

Dependency injection complaining about missing default constructor when it exists

$
0
0

I've used the dependency injection successfully with other classes but I just created a class that the injection service seems to have a problem with and I don't understand why.

The interface in the main project

namespace MyApp.Infrastructure.AbstractHelpers
{
    public interface IDataCacheHelper
    {
        void ClearData();
    }
}

The implementation in the Android project

using MyApp.Droid.Services;
using MyApp.Infrastructure.AbstractHelpers;

[assembly: Xamarin.Forms.Dependency(typeof(IDataCacheHelper))]
namespace MyApp.Droid.Infrastructure.Helpers
{
    public class DataCacheHelper : Java.Lang.Object,  IDataCacheHelper
    {
        public DataCacheHelper () 
        {}

        #region IDataCacheHelper implementation

        public void ClearData ()
        {
            GcmRegistrationService.Unsubscribe ();
        }

        #endregion

    }
}

When I try to call DependencyService.Get<IDataCacheHelper>() in the main project it says that the default constructor cannot be found.

Any thoughts?


Viewing all articles
Browse latest Browse all 77050

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>