'Cannot change thread mode after it is set

I have a C# app that I haven't worked on for a while. The last time I worked on this was with Visual Studio 2019. It still opens and runs in debug mode with VS 2019. IF OI open it with VS2022 it will not run in debug mode. I get and error:

Cannot change thread mode after it is set.

What causes this and what might the solution be?



Solution 1:[1]

Please follow the steps below:

  1. Go to project properties by right-clicking your project name in the project explorer and choosing properties
  2. In the project properties window, select Build on the left side of the list
  3. On the right side make sure you uncheck "Prefer 32-bit"
  4. Save the project
  5. Debug and test your project. This should resolve the issue.

Screenshot of Project Properties

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1