Well, the source of this issue changes from issue to issue. So if this doesn't solve your issue, be sure to read further down below.
In my case it was due to changing the default install path for new applications.
I changed the default install path to my HDD, so I don't have to manually change every new application's install path from my SSD to my HDD.
The problem is that some applications only looks at the drive on which Windows is installed.
So now I change my default install path to my SSD every time I update Unity, so Visual Studio will be installed at the path where VS Code will look for the dlls.
But sometimes this won't be enough, for example this time I wasted some time again, and still haven't figured out the correct way of doing this. Maybe I will just give in, and always manually change the install path. What I did:
- I had to uninstall Unity, Visual Studio, restart my computer
- Then install Unity, Visual Studio, restart my computer,
- In Unity > Preferences, switched the IDE to Visual Studio.
- Opened the a file, which opened Visual Studio.
- Switched the IDE to Visual Studio Code.
I've just uninstalled my old Unity, and installed the new one, and as it turns out, a Visual Studio reinstallation, and restarts aren't needed.
Just open a file with Visual Studio as an IDE, and then switch to Visual Studio Code.