0

I recently installed Visual Studio 2022 17.5.5 on my Windows 11 machine and have been trying to run a C# program. I installed Mingw64 (version 12.2.0) to see if it would solve my problem, but I'm still getting the same error message.

I tried to run the following C# code in Visual Studio 2022 on Windows 11 with Mingw64 installed:

Problem with Visual Studio:

Problem with Visual Studio

Code:

using System;

namespace Beecrowd
{
    class Problem1044
    {
        static void Main(string[] args)
        {
            String[] input = Console.ReadLine().Split(' ');

            int a = int.Parse(input[0]);
            int b = int.Parse(input[1]);

            if (a % b == 0 || b % a == 0)
            {
                Console.WriteLine("Sao Multiplos");
            }
            else
            {
                Console.WriteLine("Nao sao Multiplos");
            }
        }
    }
}

However, I received the following error message:

Unable to start program "C:\Users\Lord\Kaminski\Documents\Codes\C#\Projects\App\bin\Debug\net6.0\App.dll'.

C:\Users\Lord\Kaminski\Documents\Codes\C#\Projects\App\bin\Debug\net6.0\App.dll is not a valid Win32 application.

I installed Mingw64 (version 12.2.0) to see if it would solve the problem, but the error persists. I'm hoping someone can help me troubleshoot and resolve this error. Thank you.

wohlstad
  • 12,661
  • 10
  • 26
  • 39
  • There's a lot to process here. Why do you have directories in your solution, why does your App.cs float next to your .csproj, why do you see your bin and obj folders and what does MinGW64 have to do with all of this? Can you start over and click File -> New Project -> Console Application and go from there instead of getting this mess to work? – CodeCaster May 10 '23 at 07:51
  • 1
    But the bottom line is that you're trying to start a class library as executable. – CodeCaster May 10 '23 at 08:08
  • Please try first [Unable to start program. .dll is not a valid Win32 application error in Visual Studio 2017](https://stackoverflow.com/questions/48602869/unable-to-start-program-value-dll-is-not-a-valid-win32-application-error-in-v), especially the [method set as startup project](https://stackoverflow.com/a/61347592/20528460). If This doesn't work please let us know. – wenbingeng-MSFT May 10 '23 at 09:00

1 Answers1

-1
  • Make sure you have selected the correct startup project in Visual Studio. You can do this by right-clicking on the project that contains the executable file and choosing Set as startup project.

  • Make sure you have installed the .NET desktop development workload in Visual Studio Installer. This will ensure that you have the necessary tools and frameworks to run C# applications.

  • Make sure you are running the program in compatibility mode for your Windows version. You can do this by right-clicking on the executable file, choosing Properties, then Compatibility, and selecting the appropriate option.

If none of these steps work, you may need to manually install or replace the DLL file that is causing the error. You can use a DLL fixer tool perhaps.

Source: 1

  • Don't summarize other question's answers if you believe a question to be answered by another question; flag as duplicate instead. And: _"you may need to manually install or replace the DLL file that is causing the error. You can use a DLL fixer tool perhaps"_ - what? – CodeCaster May 10 '23 at 08:09