I am trying to open a C# solution that has been generated from a Unity v2020.3.19f project with Visual Studio 2022. Opening it with Visual Studio 2019 works just fine, but there are reasons I'd like to be able to open it with v2022 (such as GitHub Copilot). I did not have issues with this on my previous install of Windows 10.
Upon opening the solution in VS2022, I get the following pop-up prompt for every project in the solution:
Choosing the first option updates the target project to .NET Framework 4.8 and loads the project, but the whole file appears with red lines. When hovering over an underlined bool Property, the error shows as: `CS0518: Predefined type 'System.Boolean' is not defined or imported.
Choosing the second option opens this URL in my browser, prompting me to install .NET Framework 4.7.1 targeting pack (which was already installed via the Visual Studio Installer). When I try to install the .NET Framework 4.7.1 runtime, the installer responds with .NET Framework 4.7.1 or a later update is already installed on this computer. When I try to install the .NET Framework 4.7.1 Developer Pack, the installer allows me to choose from "Repair", "Uninstall", or "Cancel". Repairing has no effect.
I installed both versions of Visual Studio (2019 & 2022) the usual way through the Visual Studio Installer, along with the "Game Development with Unity" workload, which tells me it's installed all dependencies just fine:
Here's what I've tried so far:
Uninstall & reinstall all versions of Visual Studio through the Visual Studio Installer
Uninstall & reinstall Unity, with the Visual Studio module installed through Unity Hub (which just opens the Visual Studio Installer for me to choose which version I want to install)
Regenerate project files through the Unity Editor
Uninstall any references to .NET Framework through the Control Panel
Try reinstalling .NET Framework targeting pack 4.7.1 either from the Visual Studio Installer or manually through the Microsoft SDK website from the prompt
Nothing works for me. Any help on how to make VS2022 stop complaining is greatly appreciated.
Update 1: I found a couple of threads where people suggested simply pressing the Regenerate project files button in "Edit -> Preferences -> External Tools`. This has not helped me.
Update 2: I've tried everything I can possibly imagine, in different orders and different combinations. I even reinstalled Windows 10 to no avail. It's like Visual Studio just doesn't want to accept that the .NET Framework 4.7.1 targeting pack is installed. Please help :(
check this
https://learn.microsoft.com/en-us/answers/questions/733018/visual-studio-2022-cannot-locate-installed-net-fra.html
If you modified the value of ProgramFilesDir(x86), just to modify it back to C:\ProgramFiles(x86) can solve the problem
That is a very interesting problem, my main solution for you to first try is to make sure you are even targeting the correct .net framework in UNITY before you even build the solution. You are using the .NET 4.x, you need to go into your configuration settings and player settings in unity and ensure its not on a different version, for me, unity still defaults to .net standard 2.0. Follow the steps located here. To do so.
Another solution is to see if that first option actually gives you errors that prevent you from using unity, because I know that Visual Studio Code has problems occasionally where it tells me im wrong, my program is wrong, every life choice I have made was poor and I am poor, yet in unity, there are no errors showing in the console and I can hit play no problem. In that case I just had to rebuild a few times and fiddle with vs code until omnisharp stopped yelling at me.
Apperently I have been in a similar situation as when you were getting the error "Predefined type 'System.Object' is not defined or imported" because looking into it, I already have clicked on some of the links, try this one if that error persists. If you cannot prevent the errors to begin with, I would recommend you trying to fix the upgraded version from option one as that is more than likely going to get you the closest to a solution.
I have a Xamarin Forms 5 application that is having issues being debugged via Visual Studio.
The application has a root view with tabs and each has a ListView control. The application runs fine without any issues when started without debugging.
When debugging it seems that the ListViews are continually re-creating the cells, the descendants count just keeps going up indefinitely. To the point where the UI is unusable in any meaningful way due to the connection being swamped and the CPU continually hit.
It behaves this way when running either Android or iOS, hardware or simulator.
I've just loaded the exact same projects and solutions into JetBrains Rider 2021.3 and debugging using Rider works flawlessly, using both simulators and hardware.
The only common denominator is the Visual Studio debugger.
At this point I'm not entirely sure how to address the issue with debugging via Visual Studio. Are there any configuration options that would be worth experimenting with to try and solve this?
Please include your visual studio and xamarin forms version.
Possible issue : On vs you can change hot reload option in tool -> Option -> Hot reload. In the xamarin forms section, try to change the option from "Only change XF 5.0" to "Full Page".
note : the english name of those option might not be exact (my vs is in another language).
I really like the idea of working with Visual Studio, C# and Unity on OS X.
Has anyone made debugging with C# in Unity work with Visual Studio Code on OS X?
Yes it works absolutely fine. Unity is C#, JavaScript or Boo. So, you don't need .NET for it. Unity uses Mono runtime. So, an existing VS project can be opened in Unity for Mac OS X.
EDIT
Here is a link that helps you to attach a debugger to the VS endpoint.
http://www.yunspace.com/2015/01/19/integrating-visualstudio-with-unity3d-on-mac-using-vstools/
You can try VS Tools for Unity too.
http://unityvs.com
UPDATE
There is this awesome Unity Plugin by dotBunny that solves the problem and integrates Code with Unity tools.
Hi the solution is https://github.com/dotBunny/VSCode This plugin works on both MacOS and Windows and gives you the following capabilities:
•An option to enable VS Code integration (Editor –> Assets –> Enable Integration), this updates your solution files and (more importantly) keeps them in sync. This also sets the preferred external tool editor in the Unity preferences.
*Note, the old “Sync MonoDevelop” option is now gone in the Unity editor from V5.2
•It writes out the necessary (and sometimes hard to find) VS Code configuration files, including the ability to hide “non-code” files in the editor (hides things like .sln, .csproj and the ever present unity .meta files)
There are a couple of other settings in there to help speed up the integration.
•Automatically launches VS Code direct to your project folder, EVERY-TIME. no longer do you have to worry about keeping that window open, or switching around if you work on multiple projects
One thing to be aware of, once you enable the VSCode integration, changing your preferred code editor in the External Tools preferences will have no effect as the plugin takes over opening code files. If you want to use another editor, you’ll have to disable the integration first.
These are just the main highlights as there are more features in there as well.
Currently you need to download the plugin files from GitHub
An existing Visual Studio solution can be build and debugged with Visual Studio Code on the Mac with Mono. You have to use the launch.json and tasks.json files.
I described it on my blog: Compile and Debug
To build Unity in Visual Studio Code, you can hook up Mono xbuild compiler as a task runner, so you don't even have to leave IDE to have errors and warnings.
See https://twitter.com/_eppz/status/846859856787259392 for more.
It's a little unstable. But it's possible from recent VSC version.
1) Install this VSC Unity plugin-in.
https://github.com/dotBunny/VSCode/
2) Follow these commands. (Step 1, 2 and 3)
https://code.visualstudio.com/Docs/runtimes/unity
3) After you complete the settings, launch the VSC using Unity menu.
Assets/Open C# Project in Code
4) Play the Unity project.
You can see the debug port number on the unity console.
And the project's launch.json file will be renewed automatically.
To open launch.json, click option icons.
the file exists in this folder.
.vscode/launch.json
sample.
{
"version":"0.1.0",
"configurations":[
{
"name":"Unity",
"type":"mono",
"address":"localhost",
"port":56621
}
]
}
5) Start debug in VSC debug tab.
That's it. Hope this help.
Update, 2016 - the petition was popular enough that some VS Code extensions have been written for it: https://marketplace.visualstudio.com/search?term=unity&target=VSCode&sortBy=Relevance
Petition for it on the Visual Studio UserVoice page: http://visualstudio.uservoice.com/forums/293070-visual-studio-code/suggestions/7752702-unity-integration
[Feb 2017] It is now possible to do this without the dotBunny plugin.
i.e. Support is built into Unity natively.
Just to repeat, you don't need to fiddle with Unity, just VSCode.
Instructions here
Instructions are incomplete though, and I didn't take screenshots (please do!), but basically what I did was:
(...and please improve these instructions as you go, I'm working from memory...)
I deleted/renamed my .vscode/Launch.json file, as per the link.
Double-click on some file to bring up the project in VSCode (maybe first make sure that in Unity's settings you have selected VSCode as your default code editor)
clicking the bug icon then the cogwheel, as per the link.
I had to install that vscode-unity-debug plugin in VSCode, just filtering the search with 'unity' found it.
I then had to press the green 'play' triangle.
I set a breakpoint in my code.
Now over to unity and press play, and the breakpoint gets hit.
The Unity Debugger for Visual Studio Code is working, but doesn't work well enough when doing any kind of serious work for now. I really hope they will improve it in the future as I prefer VS Code over VS.
Current problems I encountered
-Sometimes I cannot step in a function, the debugger will hang until you detach
-no local variable, you have to watch everything
-some more complex variable have no support, so you can't see what is inside
-A bit overall unstable with unexpected behaviours.
What I love about it,
Attaching & Detaching is a breeze. Just press a button, allowing to attach and detach quickly as needed. e.g. At the beginning of the program I work on, there will be an bunch of exception. I can detach and attach quickly to skip the exceptions.
The problems with it are too constraining as it currently stands, I had to go back to the classic Visual Studio.
Im tearing my hair out with this one Im afraid and am down hours and hours.
Firstly I wanted to install VS Community to use with Unity. Im running windows 8.1 pro.
But I had trouble installing. Long story short there were some fonts in windows\fonts that the VS installer didnt like. So I moved the fonts and the installer ran through successfully. I then installed the VS 2013 Tools for Unity.
So then I imported the Unity VS tools to my project. Now my unity project hangs when unity opens. I fixed unity by removing the Unity VS stuff form the project directory.
I started getting errors on screen that said "An unhandled exception System.Configuration.ConfigurationErrorsException) occurred in ZAPrivacyService.exe[3168]
The Just In Time Debugger was launched without necessary security permissions etc etc
Also the above error message appears very frequently and even if i ignore the dialogue it just keeps popping up every minute or so. I just off the JIT prompts but then I get an error message saying that no JIT is available. instead of the other error message. ZAPrivacyService seems to be part of ZoneAlarm. So I downloaded and reinstalled it. No joy. I tried uninstalling the Unity VS tools. I then went to Programs and Features to remove VS. However when I click on VS I only get the option to change. So I click change and the VS splash screen briefly appears. Then nothing. I also tried rerunning the VS installer(from the ISO and the web exe) and the same thing happens.
I do want to get VS running I thought a reinstall could fix it. But not to even be able to reinstall.....
Also how can I set Vs to ignore everything except the projects im working on IN VS?
Any ideas????
Thanks
Someone asked about getting the WinRT XAML Toolkit controls to show up in Visual Studio Toolbox. I can see that they do show up when I look at the sample project that uses the source code version of the WinRT XAML Toolkit and I can find them in Blend in an app project that uses NuGet-packaged version of the Toolkit - just by searching for the controls by name, but they don't automatically show up in VS Toolbox somehow. I saw in Tim Heuer's article that you can make them show up in the Toolbox if you do a VSIX deployment, but the Toolkit doesn't support that option right now.
Is it possible to get it to work with NuGet or are using the source code or building Extension SDK the only options?
I think the possible way to do this would be to allow package manager to take additional parameters which would then add them to toolbox
If the default project templates reset the toolbox items each time, this might work great otherwise we will see versioning related issues in no time.