C
C#17mo ago
alex098304

❔ Creating new projects - Attach instead of Run

When I create any new C# project in Visual Studio 2022 (latest update, but cannot confirm whether the update is what broke it or not), the solution folder appears empty, and I cannot "Run" the program. It tries to get me to "Attach" instead. When I close the project and try to open the .sln file, the project opens correctly, but it still doesn't give me "Run" When I try to open the project from within visual studio, same issue. When I try to open really old C# projects that I have, I get a warning saying that one or more projects in the solution were not loaded correctly. I am not having this issue with any C++ projects. I can open old projects, create new projects, etc. and there are no issues.
53 Replies
TheRanger
TheRanger17mo ago
$newproject
MODiX
MODiX17mo ago
When creating a new project, prefer using .NET over .NET Framework, unless you have a very specific reason to be using .NET Framework. .NET Framework is now legacy code and only get security fix updates, it no longer gets new features and is not recommended. https://cdn.discordapp.com/attachments/569261465463160900/899381236617855016/unknown.png
alex098304
alex098304OP17mo ago
This doesn't solve my problem at all. I just created a WPF Application, verifying with this picture that I did NOT select .NET Framework, and the project still doesn't work.
Pobiega
Pobiega17mo ago
open it up in a normal file explorer are all the files there?
alex098304
alex098304OP17mo ago
I tried. All files are there. No Run button
Pobiega
Pobiega17mo ago
Open a terminal. dotnet --info show me the money
alex098304
alex098304OP17mo ago
alex098304
alex098304OP17mo ago
Pobiega
Pobiega17mo ago
Yep, I know what this is
alex098304
alex098304OP17mo ago
Please enlighten me because I do not. Thank you
Pobiega
Pobiega17mo ago
okay, open up your environment variable editing thingy Id love to tell you the name but mine is in swedish :d "edit the systems environment variables" is the name loosly translated
alex098304
alex098304OP17mo ago
you mean via visual studio?
Pobiega
Pobiega17mo ago
nah
alex098304
alex098304OP17mo ago
through the OS?
Pobiega
Pobiega17mo ago
windows ya
alex098304
alex098304OP17mo ago
ok
Pobiega
Pobiega17mo ago
Pobiega
Pobiega17mo ago
this one
alex098304
alex098304OP17mo ago
got it
Pobiega
Pobiega17mo ago
ok, so in the bottom one, find your path and click "edit" literally "Path"
alex098304
alex098304OP17mo ago
Right
Pobiega
Pobiega17mo ago
okay, show me what it says?
alex098304
alex098304OP17mo ago
won't let me edit:
alex098304
alex098304OP17mo ago
might need to run as admin one moment
Pobiega
Pobiega17mo ago
mhm yeah seems so
Pobiega
Pobiega17mo ago
Pobiega
Pobiega17mo ago
we want it to look like this
alex098304
alex098304OP17mo ago
This is what I got:
Pobiega
Pobiega17mo ago
yep okay so near the bottom you have (x86)\dotnet you probably also have a C:\Program files\dotnet even further down take the non-x86 one, and click "move up" until its ABOVE the other one okay?
alex098304
alex098304OP17mo ago
Okay. One moment
alex098304
alex098304OP17mo ago
alex098304
alex098304OP17mo ago
like so?
Pobiega
Pobiega17mo ago
yepyep okay, now restart VS and your terminal windows
alex098304
alex098304OP17mo ago
awesome. will do.
Pobiega
Pobiega17mo ago
this will make dotnet by default use the x64 SDK this is a good thing
alex098304
alex098304OP17mo ago
yeah, that seemed to do the trick
Pobiega
Pobiega17mo ago
👍 Figured it would
alex098304
alex098304OP17mo ago
can you give me a reference as to what was wrong because I like to understand why things don't work.
Pobiega
Pobiega17mo ago
2nd person today with this issue 🙂 okay, so VS actually uses the dotnet command under the hood
alex098304
alex098304OP17mo ago
will brb, please keep explaining if you have time.
Pobiega
Pobiega17mo ago
do you know what an SDK is?
alex098304
alex098304OP17mo ago
yes
Pobiega
Pobiega17mo ago
alex098304
alex098304OP17mo ago
software development kit
Pobiega
Pobiega17mo ago
look at this screenshot from your paste 🙂 NO SDKS INSTALLED now, I dont think you are an idiot. I think you installed an SDK
alex098304
alex098304OP17mo ago
yeah, I did notice that, but I was going along with your instructions lol.
Pobiega
Pobiega17mo ago
I think you installed the x64 SDK, as you should have and that was correct
alex098304
alex098304OP17mo ago
ah
Pobiega
Pobiega17mo ago
but, your system already had the x86 RUNTIME installed not the sdk, the runtime these both provide a dotnet command thou
alex098304
alex098304OP17mo ago
so the x86 stuff was above the x64 stuff that's starting to make sense, yeah
Pobiega
Pobiega17mo ago
and your x86 one took president over the other one due to path order, yes so we adjusted the order, making x64 default and voila, you have an SDK
alex098304
alex098304OP17mo ago
okay, that makes a whole lot of sense, thank you so much. have a good day
Accord
Accord17mo ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.
Want results from more Discord servers?
Add your server