Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9072821
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T18:15:51+00:00 2026-06-16T18:15:51+00:00

I seem to be confused at how to make MvvmCross detect my ViewModels that

  • 0

I seem to be confused at how to make MvvmCross detect my ViewModels that are associated with views in Mono for Android. I tried to follow TwitterSearch in implementing the navigation but it just won’t work.

RequestNavigate<LoginViewModel>();

here’s my view:

[Activity(Label = "Login")]
public class LoginActivity : MvxBindingActivityView<LoginViewModel>
{
    protected override void OnCreate(Bundle bundle)
    {
        base.OnCreate(bundle);

        App.InitializeRestConnection(this);
    }

    protected override void OnViewModelSet()
    {
        SetContentView(Resource.Layout.LoginBindable);
    }

}

here’s the exception:

I/ActivityManager(  307): Displayed com.desco.pendulum/pendulum.androidapp.SplashScreenActivity: +1s373ms (total +4s420ms)
I/Navigation( 8643):   0.50 Navigate to LoginViewModel with args
I/mono-stdout( 8643): Navigation:Diagnostic:  0.50 Navigate to LoginViewModel with args
I/MonoDroid( 8643): UNHANDLED EXCEPTION: System.Collections.Generic.KeyNotFoundException: Could not find view for dESCO.Mobile.ViewModels.LoginViewModel
I/MonoDroid( 8643): at Cirrious.MvvmCross.Views.MvxViewsContainer.GetViewType (System.Type) <0x001a4>
I/MonoDroid( 8643): at Cirrious.MvvmCross.Droid.Views.MvxAndroidViewsContainer.GetIntentFor (Cirrious.MvvmCross.Views.MvxShowViewModelRequest) <0x00023>
I/MonoDroid( 8643): at Cirrious.MvvmCross.Droid.Views.MvxAndroidViewPresenter.Show (Cirrious.MvvmCross.Views.MvxShowViewModelRequest) <0x00037>
I/MonoDroid( 8643): at Cirrious.MvvmCross.Droid.Views.MvxAndroidViewDispatcher/<>c__DisplayClass1.<RequestNavigate>b__0 () <0x0002f>
I/MonoDroid( 8643): at Java.Lang.Thread/RunnableImplementor.Run () <0x0003f>
I/MonoDroid( 8643): at Java.Lang.IRunnableInvoker.n_Run (intptr,intptr) <0x00037>
I/MonoDroid( 8643): at (wrapper dynamic-method) object.7060b187-418d-4bca-ad4f-8b9cae936501 (intptr,intptr) <0x0003b>

any suggestions?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T18:15:52+00:00Added an answer on June 16, 2026 at 6:15 pm

    I can’t see anything obviously wrong with your setup.

    The default Droid framework setup looks for classes which implement IMvxAndroidView in the ExecutingAssembly using the logic in: https://github.com/slodge/MvvmCross/blob/vnext/Cirrious/Cirrious.MvvmCross/Platform/MvxBaseSetup.cs#L200

    So I can’t see any obvious reason why your LoginActivity View isn’t being picked up.

    One quick thing you could do is to add some debug code to your Setup.cs to see what views are being detected:

      protected override IDictionary<Type, Type> GetViewModelViewLookup()
      {
          var toReturn = base.GetViewModelViewLookup();
          MvxTrace.Trace("Tracing viewModels and views");
          foreach (var kvp in toReturn)
          {
              MvxTrace.Trace("Seen pair {0} : {1}", kvp.Key.Name, kvp.Value.Name);
          }
          return toReturn;
      }
    

    If that shows the list is empty or missing your activity, then I’m afraid we’d need to step through the reflection logic to find out why it’s not picking up your Activity.


    In real desperation, you could also fake the results:

      protected override IDictionary<Type, Type> GetViewModelViewLookup()
      {
          return new Dictionary<Type,Type>() { { typeof(LoginViewModel), typeof(LoginActivity) } };
      }
    

    But this probably isn’t the right long-term solution for you


    If this is caused by some kind of ‘solution setup’ difference – e.g. if you have somehow put your Setup.cs in a different project to your views – then it may be that somehow overriding the default convention will help you.

    To achieve this, in you Setup.cs, override the code:

        public virtual Assembly ExecutableAssembly
        {
            get { return GetType().Assembly; }
        }
    
        protected override IDictionary<System.Type, System.Type> GetViewModelViewLookup()
        {
            return GetViewModelViewLookup(ExecutableAssembly, typeof (IMvxAndroidView));
        }
    

    in the base setup class – https://github.com/slodge/MvvmCross/blob/vnext/Cirrious/Cirrious.MvvmCross.Droid/Platform/MvxBaseAndroidSetup.cs

    This can be done either by overriding the ExecutingAssembly property (although this seems a bit wrong given it’s name) or by overriding the GetViewModelViewLookup method. For example, if you wanted to look in several separate assemblies you could use:

        public List<Assembly> MyViewAssemblies { get; set; }
    
        protected override IDictionary<System.Type, System.Type> GetViewModelViewLookup()
        {
            var toReturn = new Dictionary<Type, Type>();
    
            foreach (var assembly in MyViewAssemblies)
            {
                var contributions = base.GetViewModelViewLookup(assembly, typeof (IMvxAndroidView));
                foreach (var kvp in contributions)
                {
                    toReturn[kvp.Key] = kvp.Value; 
                }
            }
    
            return toReturn;
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Android styles and themes always seem to make my head spin. I wanted to
might be a stupid question but I seem to be confused. Im pretty new
As demonstrated in this answer I recently posted, I seem to be confused about
I seem to have gotten confused as to what the css clear keyword means.
I'm really confused about the visitor pattern and its uses. I can't really seem
I seem to have found a bug in jQuery UI that duplicates dragged elements
I'm confused regarding Ivy, Maven and Archiva - they all seem to be trying
I seem to have confused myself with a preg_match regex I'm doing, so fresh
I am getting confused with all the different terminology when using Android: Activity, Service...
I have a jQuery web app frontend that I would like to make GET/POST

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.