I work with Unity, and recently I came across some sort of bug with Visual Studio. For some reason one day the Script Editor stopped working.
When I first open it up through Unity, it would open as usual and seem fine, but after 5 seconds of interaction, Visual Studio would then freeze and crash without an error report. Following tries with the editor would just crash almost right away.
I did some research and found out that it was some sort of problem with Unity's MEF Cache, the Microsoft Documentation would ask me to do the following: Delete the following file: "%localappdata%\Microsoft\VisualStudio<version>\ComponentModelCache" and if the problem continues, I should run this line of code on VS' CMD as a administrator "devenv /setup".
I tried both methods with Visual Studio, but neither seemed to work, only to return to being fine for 5 seconds before freezing and crashing.
I have updated Visual Studio 2017 to the newer version and performed the same method, but the problem persists.
I would like to know if anyone have any solutions to my situation, if I should try reinstalling Visual Studio, try to reinstall Unity or just use another Script Editor.
edit: Just to inform, the version of Unity I was using was 2021.2.8f1. But I don't know if it matters since the bug didn't seem to depend on the Unity version.
I managed to fix the issue by installing Visual Studio 2022
Related
Every time I try to open a C# Script inside Unity, it immediately hangs and doesn't even open Visual Studio, this started happening after I updated Visual Studio 2017 twice, the first one was an incomplete installation since my computer restarted then the second one was completed version.
Unity still works normally for all things except opening a C# script. I tried changing the External Tools Preferences in the Edit between Visual Studio 2017 and Visual Studio 2017 (Community) but both did nothing.
When Unity hangs, I can only use Task Manager to close it and MonoDevelop isn't one of the options in the External Tools Preferences
Can you open Visual Studio when Unity is not open? Which version of Unity are you using for your project? Are you using Unity Hub to manage your versions?
Steps to try:
Reinstall VS (update to 2019 optional)
Close all background services related to VS and Unity.
If all else fails, you can clean the registry before reinstalling.
Uninstall both Unity, VS and any dependency that you have installed. Then go to Hub and download your required version with all the required dependencies.
Doing this will remove any inconsistency and also you will not have to do the external tool reference yourself.
I don't know why but after upgrading Microsoft to the insider preview version. I know, it's always a bad idea to update anything but had to do it to get the new MR Headsets to work...
I downgraded again after visual studio was unable to create any app packages. And it still doesn't work.... tried to repair visual studio and still nothing. I know it's a VS issue because i can't even build older projects which always worked and which i haven't touched.
And now after reinstalling it tells me that the package is unavailable and that i should install windows10 sdk even tho i installed it 100x already.
Edit: I'm also constantly getting this error:
And even after installing the file suggested below nothing works.
I don't get my Microsoft keeps building shit that never works..
Sounds like you should try the last resort:
https://learn.microsoft.com/en-us/visualstudio/install/remove-visual-studio
Use the InstallCleanup.exe to remove all things
There are known issues with using visual studio 2017, when doing hololens development, my stable environment is visual studio 2015 Update 3.0.0 and Unity 5.5 0f1. These I know will work together. Also, if you are trying to use the hololens toolkit, you will also have issues with the new versions of Visual Studio. So you will want to take the Dev branch and not master.
Since updating to the most recent version of Unity 5.4.0f3, whenever I doubleclick on a script, it launches both Visual Studio and Monodevelop, but I get an error saying that the this version of VS (Community 2015) is unable to open my project. Monodevelop displays it's own, somewhat less clear error message. Please see the screen shots below.
I can still manually open my script using Visual Studio's file menu, but the intellisense code completion no longer works. Anyone know how to fix this? I have Visual Studio's Tools for Unity installed.
I was having similar issues when doing a clean download of an existing Unity project onto a fresh install of Visual Studio Community 2019.
In the end the issue for me was that, although the correct version of VS Tools for Unity was installed, it was 'Disabled' by default in VS's Manage Extensions dialog (Extensions -> Manage Extensions). Just had to click 'Enable', restart Visual Studio, and all worked as expected again.
Turns out it was an issue with my existing install of Visual Studio Tools for Unity (VSTU).
I found a thread where users had experienced similar problems due to an unsupported version of VSTU running on Unity5.2 and beyond. Unity 5.2+ requires VSTU 2.1 or later for VS to work correctly with Unity, more information for anyone interested is available in the documentation here.
I had VSTU 2.3 installed, but removing and reinstalling VSTU resolved the issue, so there must have been a problem with my install. If anyone else has this or a similar issue you can download the latest installer for VSTU here. Thanks to all who chimed in your responses helped me look in the right place!
Please try following steps:
Delete old *.csproj and *.sln files on project's root folder
Check "Edit > Preferences > External Tools" and make sure you've selected "Visual Studio"
Re-open solution by "Assets > Open C# Project" menu
For me it was enough to right click the solution in Solution Explorer and run "Resolve errors".
I will complete what is said above. I experienced this issue today and it took me a while. In my case it was relative to a new install of the Unity Editor.
For some unknown reason the unity tool used on VS (intellisense) was uninstalled. I had to reinstall this : open Visual Studio Installer, select your project and reach the Gaming section where reside the tool for Unity.
The extension "Visual Studio 2019 Tools for Unity" seems no longer available for download via the extension manager. Luckily I recalled that I saw some game development features in the Visual Studio installer, so I picked that one:
It works for VS 2019 (16.11.11) and VS 2022 (17.2.0 Preview 1).
I'm a PHP developer, but recently I have to work with Visual Studio in a C# application. I don't know much about C#, just had a few experiences with it, and the problem is when I try to run/debug my code it works only for the first time. If I change ANY piece of code anywhere in the code the project won't launch anymore, all it does when I click "Debug" is open Google Chrome for me and there it hangs awaiting for "localhost" forever... This issue is driving me nuts, I can't program well if I have to restart Visual Studio whenever I change some code.
I have tried a lot of things that I found here and on Google, but nothing helped. I have fully repaired VS 2015, didn't work. Then I reinstalled it and still not working.
I had the issue on my notebook that visual studio would freeze when I open a solution who contains a UWP and two Xamarin Projects. Asp.net still works fine.
I thought maybe the installation is corrupt or there is an issue with Resharper. But I have the same issue now on another notebook who has a completly fresh installation and no Resharper installed so far.
I never had this with VS before Update 1. Any idea what might causing this?
EDIT: Turns out it was the Xamarin Plugin. After deinstall it, it works again..
This was solved with the latest update of the Xamarin VS plugin.