C
C#2y ago
Grin

❔ IDE error when trying to debug

I can't debug a very specific body of code without receiving a strange error. "No compatible code running on the thread." This is with Xamarin, a navigation bar is selected and the code within this function should run.
26 Replies
Grin
GrinOP2y ago
Vi Ness
Vi Ness2y ago
Is that breakpoint being hit?
Grin
GrinOP2y ago
Since the no compatible code only occurs when I select a side bar item I'd assume that its going into that onNavigationItemSelected and the moment it does I get that error.
Vi Ness
Vi Ness2y ago
A quick google search came up with this stackoverflow question. Have you seen it? https://stackoverflow.com/questions/46344434/xamarin-android-debugging-no-compatible-code-running
Stack Overflow
Xamarin Android debugging: No compatible code running
Context I am using VS 2017.3 to develop Xamarin.Forms application. I am trying to diagnose where and why an Exception occur on my code. I can successfully deploy run and debug my application usi...
Grin
GrinOP2y ago
I had found that awhile back but never read to the very button of the page where someone states "Exception settings were my fix" I'm not sure what exception settings are, I'm going to start googling. I've tried restoring my exceptions to default settings, that didn't work. I even tested by turning off all exceptions, still encountering this issue.
Vi Ness
Vi Ness2y ago
Is it throwing an exception?
Grin
GrinOP2y ago
An exception would be on the error list right? Nothing there anyways
Vi Ness
Vi Ness2y ago
That stackoverflow thread made it sound like it's pausing in the native code when it tries to hit your breakpoint. The top answer said they just had to hit Continue a few times to get it back into their event code. But idk if that works for you
Grin
GrinOP2y ago
Hitting continue allows the code to continue, but it doesn't actually go into the function and show me what is happening line for line, its like it steps over the entire thing and everything that should happen in that function happens.
Vi Ness
Vi Ness2y ago
This thread talks about there being two different debuggers for Android apps, maybe you could try swapping the one you're using? It seems like your breakpoint is being hit but the debugger you're using isn't able to debug wherever that code is being run https://stackoverflow.com/questions/32069462/using-microsoft-debugger-with-xamarin-android?rq=4
Stack Overflow
Using Microsoft debugger with Xamarin Android
There's an option in the Android project settings in the Android Options section on the Packaging tab that lets you choose between the Xamarin debugger or the Microsoft debugger. The Xamarin debugger
Grin
GrinOP2y ago
There isn't an option like that in here. Alot of these posts are older and the newer version of VS changed alot of things.
Vi Ness
Vi Ness2y ago
Try the C++ one
Grin
GrinOP2y ago
I think its the same error as the one on that post, gonna read about it.
Grin
GrinOP2y ago
Not the same error
Vi Ness
Vi Ness2y ago
The only answer I found to that is "Make sure you use the Xamarin debugger" XD
Grin
GrinOP2y ago
damn
Grin
GrinOP2y ago
I've even created a post about this on developercommunity https://developercommunity.visualstudio.com/t/No-compatible-code-running-on-thread-xa/10405286?. Have had this problem for a week now and just can't get myself to continue coding because of this issue.
Developer Community
Developer Community
Vi Ness
Vi Ness2y ago
Does the same thing happen if you debug elsewhere in your program?
Grin
GrinOP2y ago
no its only in that area its very specific to that
public bool OnNavigationItemSelected(IMenuItem item)
{
int id = item.ItemId;

if (id == Resource.Id.nav_camera)
{
int i = 5;
int x = 3;
if (i > x)
x += i;
// Handle the camera action
}
else if (id == Resource.Id.nav_gallery)
{

}
else if (id == Resource.Id.nav_slideshow)
{

}
else if (id == Resource.Id.nav_manage)
{

}
else if (id == Resource.Id.nav_share)
{

}
else if (id == Resource.Id.nav_send)
{

}

DrawerLayout drawer = FindViewById<DrawerLayout>(Resource.Id.drawer_layout);
drawer.CloseDrawer(GravityCompat.Start);
return true;
}
public bool OnNavigationItemSelected(IMenuItem item)
{
int id = item.ItemId;

if (id == Resource.Id.nav_camera)
{
int i = 5;
int x = 3;
if (i > x)
x += i;
// Handle the camera action
}
else if (id == Resource.Id.nav_gallery)
{

}
else if (id == Resource.Id.nav_slideshow)
{

}
else if (id == Resource.Id.nav_manage)
{

}
else if (id == Resource.Id.nav_share)
{

}
else if (id == Resource.Id.nav_send)
{

}

DrawerLayout drawer = FindViewById<DrawerLayout>(Resource.Id.drawer_layout);
drawer.CloseDrawer(GravityCompat.Start);
return true;
}
If I put a breakpoint anywhere in here it breaks
Vi Ness
Vi Ness2y ago
But you said that it does actually run the code correctly if you hit continue, yeah?
Grin
GrinOP2y ago
yep
Vi Ness
Vi Ness2y ago
Well that's good at least. I'm curious what happens if you call one of your own methods inside there and put a breakpoint in that method instead
Grin
GrinOP2y ago
I've tried that, same issue. I put a breakpoint within the function that was present within that OnNavigation and it did the same thing.
Grin
GrinOP2y ago
Grin
GrinOP2y ago
same issue every time. I actually have a friend on discord that doesn't have this issue. He downloaded xamarin and tested it, and he was able to debug no problem within this function. I imagine I may be a really rare case. I wish I could get more info from him, the version of VS he's using, why he's able to get into it. But he's been ghosting me a bit because I've been overburdening on the issue.
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server