none
Assembly to be debugged was built with a platform incompatible with current platform C# RRS feed

  • Question

  • I am using Visual studio professional 2019, Version 16.6.0 dot net framework 4.8.03761. I updated the visual studio and now my C# applications will not debug.

    Target Framework is .net 4.7.2 Output type is Windows Application.

    Under build Platform target is set to ANY CPU Prefer 32 bit is unchecked.

    My system is 64 bit Windows 10 Enterprise.

    I get "Error while trying to run project: Cannot start debugging. The assembly to be debugged was built with a platform incompatible with the current system."

    This is now happening with all my C# solutions.

    I believe there is a configuration setting somewhere I am missing.

    This application is a standard C# application it does not use any externally built DLL it was built created with the wizard for c#.

    The application worked fine until I updated Visual studio. to the newest version.

    I have reinstalled - repaired the installation/

    I have selected Any CPU in configurations.

    If I change the configuration it to x64 or x86 it will work but not after I reload the project. I then have to delete the configuration and recreate it for it to debug.

    The application will execute outside of the debugger on the command line and launch the UI with no issues.

    Configuration Properties are set to Debug Any CPU with the Build box checked.

    If someone else loads the solution in the visual studio the application works and debugs fine.

    I have deleted the application and reloaded from the base that works from configuration management, unchanged from when it worked. I get the same issue.

    Saturday, May 30, 2020 5:44 PM

All replies

  • I found the error, it seems a user variable was set for the platform when cross-compiling another application this was not cleaned up and it caused Visual studio to inadvertently set the Platform architecture to ARM so no matter what you set the platform to while debugging in the UI it was defaulting to the system environment variable. When the debugger launches I think it validates against this environment variable set for the system and not the project it seems like a bug. Removing the environment variable specifying the platform resolves the issue.

    As a note, if using multiple build systems and visual studio it is possible to have conflicts with visual studio platform options that are not reset by the solution when changing configurations within the configuration manager.

    Monday, June 1, 2020 6:23 PM