C
C#3w ago
UKPL

✅ "Build failed. Fix the compilation errors and try again."

So I started C# just a week ago and I've been struggling with a weird error message whenever I do dotnet run in the console. Everything was going just fine as soon as I add the int[] correctAnswers = {2, 2, 1}; to the code. Even after I removed it, the error is still the same... I do have .NET version 8.0 and every needed extension installed so I don't really understand why it's popping out. I've been trying to seek the answer on YouTube or via ChatGPT but they both failed. I'd love some help. The code:
using System;
class Program {
static void Main(string[] args) {
Console.WriteLine("e");

string[] pytania = {
"1. Ile nóg ma pająk?",
"2. Która planeta jest najbliżej Słońca?",
"3. Stolica Polski to?"
};

string[,] odpowiedzi = {
{"1. Sześć", "2. Osiem", "3. Cztery"},
{"1. Wenus", "2. Merkury", "3. Mars"},
{"1. Warszawa", "2. Wrocław", "3. Gdańsk"}
};

int[] correctAnswers = {2, 2, 1};
}
}
using System;
class Program {
static void Main(string[] args) {
Console.WriteLine("e");

string[] pytania = {
"1. Ile nóg ma pająk?",
"2. Która planeta jest najbliżej Słońca?",
"3. Stolica Polski to?"
};

string[,] odpowiedzi = {
{"1. Sześć", "2. Osiem", "3. Cztery"},
{"1. Wenus", "2. Merkury", "3. Mars"},
{"1. Warszawa", "2. Wrocław", "3. Gdańsk"}
};

int[] correctAnswers = {2, 2, 1};
}
}
13 Replies
Angius
Angius3w ago
Works just fine for me:
No description
Angius
Angius3w ago
Weird that it would just randomly break like that Do you have any other files in the project?
UKPL
UKPLOP3w ago
uh well obj folder bin folder but idk if you mean these
UKPL
UKPLOP3w ago
No description
Angius
Angius3w ago
Yeah, that seems just fine Huh Try deleting bin and obj, and run dotnet run again?
UKPL
UKPLOP3w ago
they just randomly keep getting back and when I remove obj it needs admin permission to remove it
Angius
Angius3w ago
Sure, they are generated when the project builds Which is why they're safe to delete, they'll be regenerated anyway Can't you delete it with admin perms?
UKPL
UKPLOP3w ago
i can
CSC : error CS2012: Nie można otworzyć „C:\Users\lenovo\Desktop\Giganci\L1\pierwszyQuiz\obj\Debug\net8.0\refint\pierwszyQuiz.dll” do zapisu — „Access to the path
'C:\Users\lenovo\Desktop\Giganci\L1\pierwszyQuiz\obj\Debug\net8.0\refint\pierwszyQuiz.dll' is denied.” [C:\Users\lenovo\Desktop\Giganci\L1\pierwszyQuiz\pierwszyQu
iz.csproj]

Kompilacja nie powiodła się. Napraw błędy kompilacji i uruchom ją ponownie.
CSC : error CS2012: Nie można otworzyć „C:\Users\lenovo\Desktop\Giganci\L1\pierwszyQuiz\obj\Debug\net8.0\refint\pierwszyQuiz.dll” do zapisu — „Access to the path
'C:\Users\lenovo\Desktop\Giganci\L1\pierwszyQuiz\obj\Debug\net8.0\refint\pierwszyQuiz.dll' is denied.” [C:\Users\lenovo\Desktop\Giganci\L1\pierwszyQuiz\pierwszyQu
iz.csproj]

Kompilacja nie powiodła się. Napraw błędy kompilacji i uruchom ją ponownie.
Translated:
CSC : error CS2012: Cannot open 'C:\Users\lenovo\Desktop\Giganci\L1\pierwszyQuiz\obj\Debug\net8.0\refint\pierwszyQuiz.dll' for writing — 'Access to the path
'C:\Users\lenovo\Desktop\Giganci\L1\pierwszyQuiz\obj\Debug\net8.0\refint\pierwszyQuiz.dll' is denied.' [C:\Users\lenovo\Desktop\Giganci\L1\pierwszyQuiz\pierwszyQuiz.csproj]

Build failed. Fix the compilation errors and try again.
CSC : error CS2012: Cannot open 'C:\Users\lenovo\Desktop\Giganci\L1\pierwszyQuiz\obj\Debug\net8.0\refint\pierwszyQuiz.dll' for writing — 'Access to the path
'C:\Users\lenovo\Desktop\Giganci\L1\pierwszyQuiz\obj\Debug\net8.0\refint\pierwszyQuiz.dll' is denied.' [C:\Users\lenovo\Desktop\Giganci\L1\pierwszyQuiz\pierwszyQuiz.csproj]

Build failed. Fix the compilation errors and try again.
that comes after dotnet run
Angius
Angius3w ago
Ah Could be OneDrive issue Place the projects literally anywhere but desktop or My Documents Make a C:/Projects folder or some such Or make it on a different drive if you have it
UKPL
UKPLOP3w ago
and now it should work? omg it does! thank you so much man
Angius
Angius3w ago
Yeah No problem, anytime :Ok:
UKPL
UKPLOP3w ago
i hope you have very good day or night
Angius
Angius3w ago
Likewise
Want results from more Discord servers?
Add your server