No compatible code running on the thread
I know what is causing this, but the solution evades me, because many of the answers are "I upgraded to the next VS version", which is not helpful.
What is causing this: I have a class (record) that overrides the AutomationId
property of a UI object, and once I implemented that, I get this error. The other thing to note is that my class that is creating the objects is not XAML based, that is, it doesn't have a ui.xaml
/ui.xaml.cs
pair. It's just ui.cs
which builds the widgets.
Here's a snippet of code that injects the AutomationId:
foreach (DashboardItem item in DashboardItems)
{
DashboardButton button = new()
{
Text = item.Text,
SubText = item.SubText,
AutomationId = item.AutomationId
};
}
.NET MAUI
-
Leon Lu (Shanghai Wicresoft Co,.Ltd.) 75,581 Reputation points • Microsoft Vendor
2024-06-24T07:47:47.8366667+00:00 Can you share code about DashboardButton?
Do you want to execute the UITest by setting Element.AutomationId Property?
AutomationId value only be set once on an element. Please do not set many times.
What is your VS version?
Which platform do you have this issue?
-
Russell Hires 0 Reputation points
2024-06-24T15:45:51.83+00:00 I've read that a lot of the possible solutions relate to the environment that the app runs in but nothing really says why it's the environment or what in the environment might be causing the problem. But I checked my environment and it's definitely the literal, physical mobile device and the emulated device that are the issue, because this doesn't happen when I run my app against a Windows environment.
Perhaps the better set of questions and answers is how to troubleshoot this issue. What do I need to look for? Where would I look for it? Since I know it's in my tablets (both real and emulated), what in the tablet environment could cause this to happen? What variables would I change in the environment?
VS info:
Microsoft Visual Studio Professional 2022
Version 17.10.3
VisualStudio.17.Release/17.10.3+35013.160
Microsoft .NET Framework
Version 4.8.09032
Installed Version: Professional
ADL Tools Service Provider 1.0
This package contains services used by Data Lake tools
ASA Service Provider 1.0
ASP.NET and Web Tools 17.10.341.11210
ASP.NET and Web Tools
Azure App Service Tools v3.0.0 17.10.341.11210
Azure App Service Tools v3.0.0
Azure Data Lake Tools for Visual Studio 2.6.5000.0
Microsoft Azure Data Lake Tools for Visual Studio
Azure Functions and Web Jobs Tools 17.10.341.11210
Azure Functions and Web Jobs Tools
Azure Stream Analytics Tools for Visual Studio 2.6.5000.0
Microsoft Azure Stream Analytics Tools for Visual Studio
C# Tools 4.10.0-3.24312.19+771f269b3abcbbd991f05becf8fe5e991d24b0c1
C# components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.
Code Cleanup On Save 1.0.12
Automatically run one of the Code Clean profiles when saving the document. This ensures your code is always formatted correctly and follows your coding style conventions.
CodeMaid 12.0
CodeMaid is an open source Visual Studio extension to cleanup and simplify our C#, C++, F#, VB, PHP, PowerShell, R, JSON, XAML, XML, ASP, HTML, CSS, LESS, SCSS, JavaScript and TypeScript coding.
Common Azure Tools 1.10
Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.
Extensibility Message Bus 1.4.39 (main@e8108eb)
Provides common messaging-based MEF services for loosely coupled Visual Studio extension components communication and integration.
GitHub Copilot 0.2.889.30432
GitHub Copilot is an AI pair programmer that helps you write code faster and with less work.
Microsoft Azure Hive Query Language Service 2.6.5000.0
Language service for Hive query
Microsoft Azure Stream Analytics Language Service 2.6.5000.0
Language service for Azure Stream Analytics
Microsoft JVM Debugger 1.0
Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines
Mono Debugging for Visual Studio 17.10.8 (a565b86)
Support for debugging Mono processes with Visual Studio.
NuGet Package Manager 6.10.1
NuGet Package Manager in Visual Studio. For more information about NuGet, visit https://docs.nuget.org/
Rainbow Braces 1.0.161
Colorizes matching brace pairs to make it easy to identify them and their scope. Works for curly brackets, parentheses, and square brackets.
Razor (ASP.NET Core) 17.10.3.2427201+4f57d1de251e654812adde201c0265a8ca7ca31d
Provides languages services for ASP.NET Core Razor.
SQL Server Data Tools 17.10.172.0
Microsoft SQL Server Data Tools
StylerPackage Extension 1.0
StylerPackage Visual Stuido Extension Detailed Info
ToolWindowHostedEditor 1.0
Hosting json editor into a tool window
TypeScript Tools 17.0.30327.2001
TypeScript Tools for Microsoft Visual Studio
Visual Basic Tools 4.10.0-3.24312.19+771f269b3abcbbd991f05becf8fe5e991d24b0c1
Visual Basic components used in the IDE. Depending on your project type and settings, a different version of the compiler may be used.
Visual F# Tools 17.10.0-beta.24228.1+dd749058c91585e9b5dae62b0f8df892429ee28f
Microsoft Visual F# Tools
Visual Studio IntelliCode 2.2
AI-assisted development for Visual Studio.
VisualStudio.DeviceLog 1.0
Information about my package
VisualStudio.Mac 1.0
Mac Extension for Visual Studio
Web Compiler 1.14.11
Compiler for LESS, Sass and CoffeeScript files
Xamarin 17.10.0.110 (main@cf2e960)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.
Xamarin Designer 17.10.3.10 (remotes/origin/d17-10@3beef58f89)
Visual Studio extension to enable Xamarin Designer tools in Visual Studio.
Xamarin.Android SDK 13.2.2.0 (d17-5/45b0e14)
Xamarin.Android Reference Assemblies and MSBuild support.
Mono: d9a6e87 Java.Interop: xamarin/java.interop/d17-5@149d70fe SQLite: xamarin/sqlite/3.40.1@68c69d8 Xamarin.Android Tools: xamarin/xamarin-android-tools/d17-5@ca1552d
-
Leon Lu (Shanghai Wicresoft Co,.Ltd.) 75,581 Reputation points • Microsoft Vendor
2024-06-25T09:31:02.5866667+00:00 When are you running in the Android emulator, it is working. This error only happened in your tablets, right?
-
Russell Hires 0 Reputation points
2024-06-25T11:55:49.32+00:00 No, it doesn't matter if it's an emulated tablet or a real one. The result is the same. What I don't get is why it "breaks" into separate threads at this point. I suspect that it's the AutomationId. You cautioned that setting the AutomationId multiple times is a bad idea, but this is the only time it's being set. Prior to this point, it's null.
I tried to back it all the way out and everything got worse in the sense that it breaks more often and more places when I go to debug. I have to use the F5 key a lot to get through so it can finish whatever it's doing.
I just want it to stop doing this, but idk what's making it do this in the first place. Any thoughts on my questions about how to better troubleshoot this issue? (For the sake of clarity, here's my questions again: What do I need to look for? Where would I look for it? Since I know it's in my tablets (both real and emulated), what in the tablet environment could cause this to happen? What variables would I change in the environment?)
Thanks.
-
Russell Hires 0 Reputation points
2024-06-25T12:09:00.42+00:00 No, it reaches this point whether it's the actual tablet, or the emulated one. The result is the same. I've included a screenshot to show how it "breaks" into threads at this point, when setting the AutomationId. You cautioned against setting this value more than once, but as far as I know, it's only getting set here at this point, because it's null until this block. As a reminder, there's no corresponding XAML; the buttons are created entirely programmatically, which is why I'm setting the AutomationId like this in the first place.
I really just want it to stop doing this, but I have no idea why it does in the first place. I tried taking the AutomationId out, but strangely, the number of times it breaks goes up - both more often and in more places. (That may be the same thing now that I think about it)
Any thoughts on my previous questions on how to troubleshoot this issue? (repeating them here for convenience) What do I need to look for? Where would I look for it? Since I know it's in my tablets (both real and emulated), what in the tablet environment could cause this to happen? What variables would I change in the environment?
Thanks!
-
Leon Lu (Shanghai Wicresoft Co,.Ltd.) 75,581 Reputation points • Microsoft Vendor
2024-06-27T08:19:22.5+00:00 Can you share a mini demo with us that I can reproduce this issue?
Sign in to comment