Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUG- Livesharp causing System.Reflection.AmbiguousMatchException #44

Open
EmilAlipiev opened this issue Dec 28, 2019 · 5 comments
Open

Comments

@EmilAlipiev
Copy link

EmilAlipiev commented Dec 28, 2019

I have 2 dot not core project one references to another and when I install livesharp on both of them, it throws this exception. exactly this one in the reference xamarin/Xamarin.Forms#2632

@ionoy
Copy link
Contributor

ionoy commented Dec 30, 2019

Thanks for the feedback! Can you post the exception with the stack trace?

@EmilAlipiev
Copy link
Author

somehow this error has gone now but i am getting another error. I have Xamarin.Forms.Init in MainActivity of Android project. why does it complain?


error: Initialization failed
System.InvalidOperationException: You MUST call Xamarin.Forms.Init(); prior to using it.
  at Xamarin.Forms.Device.get_PlatformServices () [0x00007] in D:\a\1\s\Xamarin.Forms.Core\Device.cs:87 
  at Xamarin.Forms.Device.BeginInvokeOnMainThread (System.Action action) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\Device.cs:104 
  at LiveSharp.Support.XamarinForms.XamarinFormsInspector.StartInspector () [0x00001] in <13a2553fe443423c92f1ff1789a644ee>:0 
  at LiveSharp.Runtime.LiveSharpInspectorHandler..ctor (LiveSharp.ServerClient.LiveServerClient client, LiveSharp.Runtime.ILiveSharpInspector inspector) [0x0002e] in <2e10542745d14bb2bb1d7a09cbdec28f>:0 
  at LiveSharp.Runtime.LiveSharpRuntime.StartInspector (System.Type inspectorType) [0x0003b] in <2e10542745d14bb2bb1d7a09cbdec28f>:0 
  at LiveSharp.Runtime.LiveSharpRuntime+<>c__DisplayClass17_0.<Start>b__0 () [0x00067] in <2e10542745d14bb2bb1d7a09cbdec28f>:0 
error: Initialization failed
System.InvalidOperationException: You MUST call Xamarin.Forms.Init(); prior to using it.
  at Xamarin.Forms.Device.get_PlatformServices () [0x00007] in D:\a\1\s\Xamarin.Forms.Core\Device.cs:87 
  at Xamarin.Forms.Device.BeginInvokeOnMainThread (System.Action action) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\Device.cs:104 
  at LiveSharp.Support.XamarinForms.XamarinFormsInspector.StartInspector () [0x00001] in <13a2553fe443423c92f1ff1789a644ee>:0 
  at LiveSharp.Runtime.LiveSharpInspectorHandler..ctor (LiveSharp.ServerClient.LiveServerClient client, LiveSharp.Runtime.ILiveSharpInspector inspector) [0x0002e] in <2e10542745d14bb2bb1d7a09cbdec28f>:0 
  at LiveSharp.Runtime.LiveSharpRuntime.StartInspector (System.Type inspectorType) [0x0003b] in <2e10542745d14bb2bb1d7a09cbdec28f>:0 
  at LiveSharp.Runtime.LiveSharpRuntime+<>c__DisplayClass17_0.<Start>b__0 () [0x00067] in <2e10542745d14bb2bb1d7a09cbdec28f>:0 

@ionoy
Copy link
Contributor

ionoy commented Jan 20, 2020

How do you initialize your application? Usually, I see code similar to following:

        protected override void OnCreate(Bundle bundle)
        {
            TabLayoutResource = Resource.Layout.Tabbar;
            ToolbarResource = Resource.Layout.Toolbar;

            base.OnCreate(bundle);

            global::Xamarin.Forms.Forms.Init(this, bundle);
            LoadApplication(new App());
        }

So Forms.Init(this, bundle); is called before the App constructor. Is there something different in your project?

Thanks!

@EmilAlipiev
Copy link
Author

yes this is correct, exactly how i do but I believe problem could be related to that my MainActivity is not set as mainlauncher.

    [Activity(Label = "myApp",
        Icon = "@drawable/icon",
        Theme = "@style/MyTheme",
         MainLauncher = false,
        ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation, LaunchMode = LaunchMode.SingleTask)]
    public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity

i am using splashactivity as mainlauncher and it will call mainactivity as shown below. not sure if that could be the problem.

public class SplashActivity : AppCompatActivity
   {
       protected override void OnCreate(Bundle bundle)
       {
           base.OnCreate(bundle);

           Intent intent = new Intent(this, typeof(MainActivity));
           GetIntentActions(intent);

       
           StartActivity(intent);
           Finish();
     
       }

i hope this info helps. otherwise i can try to create a repro later.

@ionoy
Copy link
Contributor

ionoy commented Jan 22, 2020

If your offer about a repro still stands, I would appreciate it since I couldn't reproduce it on my machine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants