AndroidRuntime Caused by: android.runtime.JavaProxyThrowable:
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. --->
Microsoft.Practices.ServiceLocation.ActivationException: Cannot register: No public constructor found in MainViewModel.
at GalaSoft.MvvmLight.Ioc.SimpleIoc.GetConstructorInfo (System.Type serviceType) [0x0012d] in :0
at GalaSoft.MvvmLight.Ioc.SimpleIoc.Register[TClass] (System.Boolean createInstanceImmediately) [0x000a5] in :0
at GalaSoft.MvvmLight.Ioc.SimpleIoc.Register[TClass] () [0x00000] in :0
at VendorEzeeAccessApp.ViewModel.ViewModelLocator..ctor () [0x0002f] in :0
at (wrapper managed-to-native) System.Reflection.MonoCMethod:InternalInvoke (System.Reflection.MonoCMethod,object,object[],System.Exception&)
at System.Reflection.MonoCMethod.InternalInvoke (System.Object obj, System.Object[] parameters) [0x00002] in :0
--- End of inner exception stack trace ---
at System.Reflection.MonoCMethod.InternalInvoke (System.Object obj, System.Object[] parameters) [0x00017] in :0
at System.RuntimeType.CreateInstanceMono (System.Boolean nonPublic) [0x000a8] in :0
at System.RuntimeType.CreateInstanceSlow (System.Boolean publicOnly, System.Boolean skipCheckThis, System.Boolean fillCache, System.Threading.StackCrawlMark& stackMark) [0x00009] in :0
at System.RuntimeType.CreateInstanceDefaultCtor (System.Boolean publicOnly, System.Boolean skipCheckThis, System.Boolean fillCache, System.Threading.StackCrawlMark& stackMark) [0x00027] in :0
at System.Activator.CreateInstance (System.Type type, System.Boolean nonPublic) [0x00020] in :0
at System.Activator.CreateInstance (System.Type type) [0x00000] in :0
at Xamarin.Forms.Xaml.CreateValuesVisitor.Visit (Xamarin.Forms.Xaml.ElementNode node, Xamarin.Forms.Xaml.INode parentNode) [0x00253] in :0
at Xamarin.Forms.Xaml.ElementNode.Accept (Xamarin.Forms.Xaml.IXamlNodeVisitor visitor, Xamarin.Forms.Xaml.INode parentNode) [0x000b1] in :0
at Xamarin.Forms.Xaml.ElementNode.Accept (Xamarin.Forms.Xaml.IXamlNodeVisitor visitor, Xamarin.Forms.Xaml.INode parentNode) [0x00089] in :0
at Xamarin.Forms.Xaml.RootNode.Accept (Xamarin.Forms.Xaml.IXamlNodeVisitor visitor, Xamarin.Forms.Xaml.INode parentNode) [0x00054] in :0
at Xamarin.Forms.Xaml.XamlLoader.Visit (Xamarin.Forms.Xaml.RootNode rootnode, Xamarin.Forms.Xaml.HydratationContext visitorContext) [0x0005a] in :0
at Xamarin.Forms.Xaml.XamlLoader.Load (System.Object view, System.String xaml) [0x0005d] in :0
at Xamarin.Forms.Xaml.XamlLoader.Load (System.Object view, System.Type callingType) [0x0002f] in :0
at Xamarin.Forms.Xaml.Extensions.LoadFromXaml[TXaml] (TXaml view, System.Type callingType) [0x00000] in :0
at VendorEzeeAccessApp.App.InitializeComponent () [0x00000] in :0
at VendorEzeeAccessApp.App..ctor () [0x00006] in :0
at VendorEzeeAccessApp.Droid.MainActivity.OnCreate (Android.OS.Bundle bundle) [0x0003f
App.xaml.cs
private void navigationConfiguration()
{
nav = new NavigationServiceVn();
if (!SimpleIoc.Default.IsRegistered<INavigationServices>())
{
//Registering the navigation for each page to navigation service
((NavigationServiceVn)nav).Configure(ViewModelLocator.MainPage, typeof(MainPage));
((NavigationServiceVn)nav).Configure(ViewModelLocator.RegistrationPage, typeof(RegistrationPage));
((NavigationServiceVn)nav).Configure(ViewModelLocator.SearchPage, typeof(SearchPage));
((NavigationServiceVn)nav).Configure(ViewModelLocator.POItemsListPage, typeof(POItemsListPage));
((NavigationServiceVn)nav).Configure(ViewModelLocator.DetailsPage, typeof(DetailsPage));
((NavigationServiceVn)nav).Configure(ViewModelLocator.AccountInfoPage, typeof(AccountInfoPage));
((NavigationServiceVn)nav).Configure(ViewModelLocator.ForgotPasswordPage, typeof(ForgotPasswordPage));
((NavigationServiceVn)nav).Configure(ViewModelLocator.AddAdminPage, typeof(AddAdminPage));
((NavigationServiceVn)nav).Configure(ViewModelLocator.AboutPage, typeof(AboutPage));
((NavigationServiceVn)nav).Configure(ViewModelLocator.ChangePasswordPage, typeof(ChangePasswordPage));
((NavigationServiceVn)nav).Configure(ViewModelLocator.ViewAdminsPage, typeof(ViewAdminsPage));
((NavigationServiceVn)nav).Configure(ViewModelLocator.AdminVendorApprovalPage, typeof(AdminVendorApprovalPage));
((NavigationServiceVn)nav).Configure(ViewModelLocator.WebViewPage, typeof(WebViewPage));
((NavigationServiceVn)nav).Configure(ViewModelLocator.WebViewPageIOS, typeof(IOSWebViewPage));
SimpleIoc.Default.Register<INavigationServices>(() => nav);
}
else
{
nav = SimpleIoc.Default.GetInstance<INavigationServices>();
}
ViewModelLocator.cs
public ViewModelLocator()
{
ServiceLocator.SetLocatorProvider(() => SimpleIoc.Default);
**SimpleIoc.Default.Register<MainViewModel>();**
SimpleIoc.Default.Register<RegistrationViewModel>();
SimpleIoc.Default.Register<SearchViewModel>();
SimpleIoc.Default.Register<POItemsListViewModel>();
SimpleIoc.Default.Register<DetailViewModel>();
SimpleIoc.Default.Register<SettingsViewModel>();
SimpleIoc.Default.Register<ForgotPasswordViewModel>();
SimpleIoc.Default.Register<MenuViewModel>();
SimpleIoc.Default.Register<AdminVendorApprovalViewModel>();
}
** public const string MainPage = "MainPage";**
public const string RegistrationPage = "RegistrationPage";
public const string SearchPage = "SeachPage";
public const string POItemsListPage = "POItemsListPage";
public const string DetailsPage = "DetailsPage";
public const string ForgotPasswordPage = "ForgotPasswordPage";
public const string AccountInfoPage = "AccountInfoPage";
public const string AddAdminPage = "AddAdminPage";
public const string AboutPage = "AboutPage";
public const string ChangePasswordPage = "ChangePasswordPage";
public const string ViewAdminsPage = "ViewAdminsPage";
public const string AdminVendorApprovalPage = "AdminVendorApprovalPage";
public const string WebViewPage = "WebViewPage";
public const string WebViewPageIOS = "WebViewPageIOS";
public MainViewModel Main
{
get
{
return ServiceLocator.Current.GetInstance<MainViewModel>();
}
}
MainViewModel.cs
public class MainViewModel : ViewModelBase
{
..............................
string loginRole = RoleEnumClass.Vendor.ToString();
// RegisterParser RegParser = new RegisterParser();
private MD5HashHelper md5helper = new MD5HashHelper();
private INavigationServices _navigation;
private GlobalMethods globalMethods = new GlobalMethods();
private StoredUserDetailsModel user = new StoredUserDetailsModel();
**public MainViewModel(INavigationServices navigation)**
{
_navigation = navigation;
setPageData();
MessagingCenter.Subscribe<EventArgs>(this, "onUsernameUnFocus", onUsernameUnFocus);
App.getAppSettingsData();
}
Application is working in debug mode but not in release mode. I am trying since two days please help me.