I recently upgraded my Unity C# project's .NET version from 3.5 to 4.5.2. Everything compiles beautifully in my Visual Studio project, but i have errors in my Unity Console which are not showing in VS and these errors are prohibiting me from running my project. It seems as though my project didn't actually upgrade to 4.5.2, is there any way to solve this?
EDIT: i've tried upgrading unity's framework version by going into Edit -> Project Settings -> Player -> Configuration -> Scripting Runtime Version and changing that value to .NET 4.x Equivalent but it changed nothing
Do you have a copy of the MySql.Data.dll in your Assets folder? References in Unity work differently than in Visual Studio. You add a reference in Unity by dropping the .dll into the Assets folder (preferably in a directory that makes sense, not at the root so that it is easy to find and doesn't clutter the root). You should always get your code working in Unity first and then compile in Visual Studio, not the other way around.
Related
When I try to right click (in the Solution Explorer) and add the existing project to solution, I get the error:
The .NET Core SDK cannot be located. .NET Core debugging will not be enabled. Make sure the .NET Core SDK is installed and is on the path
I checked here (where they get the same error on VS Code) and tried repairing, installing, reinstalling Visual Studio and my .Net 6.0 and 7.0 SDKs. Made sure to install the SDKs even with VS not open, even after a fresh restart. Nothing worked. Plus, some of those solutions seemed specific to VS code, not VS Studio.
Not sure how relevant this detail is, but this my first attempt at installing Visual Studio on this computer.
The problem persisted regardless of project type (WPF and Console were attempted), .Net version (tried making .Net 6.0 and 7.0 apps, which are the 2 sdks I've got installed), and whether or not I indicated I wanted the project and solution in the same directory.
Those were my guesses, and nothing's worked.
Here's what it looks like when I create a new project:
Open visual studio installer and make sure you have installed .Net Framework Developer correctly.
Select .Net 6.0 on this page
Can you create a wpf .net 6 project according to this flow.
If it still doesn't work, please try the repair button in the installer.
The problem turned out to be that the SDKs weren't ordered correctly in the environment variables. C:\Program Files (x86)\dotnet was listed before C:\Program Files\dotnet. I found the solution here.
Not exactly a duplicate issue though, as issues were sort of different, but had the same fix.
I have a project (.NET Core targeting .NET 4.6.1) that has lots of libraries in it. When I build the project from Visual Studio all assemblies are created correctly.
But when I delete the bin and obj folders and try to rebuild from PowerShell with dotnet publish, one of the libraries' assembly gets created badly; it's only half the file size and it doesn't work when I run the functionalities of that library.
The problem exist because I need to publish it through Team City so I can't do it from Visual Studio.
Anybody got any idea why it's behaving like this?
I recently included a .net 4.6.2 project to use with my .net core 2.1 app. But after I've done this the projects stopped to compile throwing this error:
Error Your project does not reference ".NETFramework,Version=v4.6.2"
framework. Add a reference to ".NETFramework,Version=v4.6.2" in the
"TargetFrameworks" property of your project file and then re-run NuGet
restore. SelfSignCertificateAssistant
The project stopped to compile even for another pure 4.6.2 solution. Needless to say it was working just fine before.
There was absolutely nothing that was changed in the project, so I'm not sure how to fix this:
As i figured in most cases solution proposed by #Chris should work. But for some unknown reason my Visual Studio just refused to compile it throwing the same error. I tried to re-download the project, re-reference frameworks, restarting VS...
What helped me is physically deleting project folder and then re-downloading it from source control. After this was done i was able to successfully compile it. Not sure what was the problem though.
In Visual Studio go to Tools > Options... and in the left pane, scroll down and select Nuget Package Manager. Then, check the boxes under General that say "Allow nuget to download missing packages" and "Automatically check for missing packages during build in Visual Studio".
Once you do that, try rebuilding your project and nuget should then restore any missing packages for your project.
I have been using Visual Studio 2015 community (version 14.0.25123.00 Update 2) with .Net framework v4.6.01038 with Unity Tools for VS2015 which I used to debug my unity projects. Everything seemed to work fine but after I tried to work with UnityEngine.UI VS start showing errors saying that the namespace can't be found. I have used the exact same project files in to another pc where the only difference was in .Net framework version (v4.6.01055)and that worked. If I remove the unity tools from my previous pc, the build error goes away but I guess there is no way to debug without the unity tools. Is this a issue with .net framework or I am missing something?
- I tried to export and re-import all unity assets and packages but that did not solve the issue
- VS2015 was uninstalled and reinstalled from scratch - still did not work
- unity tools was also reinstalled
- Also deleted the projectFolder\Library\UnityAssemblies folder and restarted VS2005.
None of these methods seems to work for me. Tried to find the exact version of .net framework but failed too. Is there a specific solution to this problem?
So I finally found a workaround of this issue and I pretty much think that the .Net framework version was not occurring any problem here. The solution is to Setting the Api Compatibility Level from ".NET 2.0 Subset" to ".NET 2.0". To do this in unity perform the following steps:
Unity > Edit > Project Settings > Player > Api Compatibility Level
From: ".NET 2.0 Subset"
To ".NET 2.0"
Do perform a restart to both Unity and VS2015 (if the above solution doesn't work right then)
Go to: Edit > Preference > External Tools. in External script editor > click on browse > go to unity file > Editor File and click on mono develop.
I have several projects in a large solution that won't convert to V4.5.1 (or even V4.5). Most did, but obviously I need to get all of them converted. The GUI in Visual Studio says that it did it and reloads the project, but if you go back into the properties it still says V4 and it won't compile because of dependencies that converted properly and are V4.5.1
I tried manually updating the .csproj files and it says 4.5.1 as the target framework, and I even updated the app.config/web.config to point to the right version, however Visual Studio's property page still says .NET 4 and is throwing compile errors because it can't access the ones that successfully updated to 4.5.1
What am I missing in the process to get these updated? I've tried VS.net 2012 and 2013 and both do the same thing.
In hopes that this helps others:
In our case, the issue was that we were referencing a custom targets file that was created for the entire solution. even though the project was getting updated, the custom targets file was overriding it thus preventing the project from getting updated.
Updated the targets file to point to .net 4.5 and everything was fine.
For me, the solution was to remove all the extraneous <PropertyGroup> sections from the .csproject file - except the first one.
VS 2015 was setting the <TargetFramework> to 4.5.1 on only one of them (not the first one).
After two days of suffering, I have created a new project, targeted .NET 4.5 and then manually copied all files from the existing project. Made sure new project compiles. Removed old project. Moved new project into the directory of the old project so that I can reverse merge into trunk. Job done.
Project I was upgrading was an old WPF project with thousands (no kidding) XAML files in a single project. It also had a release preview of MvvmLight (years old) and an older version of Prism along with a range of other libraries. All and all the project is a mess and somebody must have done something really stupid to make targeting .NET 4.5 this difficult.
I had a similar issue. Turns out the DLLs were built for target framework 4.5.1, but the project I was working in was built for 4.5 only. There were some suppressed warning messages when I compiled. When I showed compile warnings, that was the hint that told me what was going on.
I recompiled the DLLs for framework 4.5, and then the DLLs copied automatically without needing additional references to the assemblies.
In my case I was working with projects designed for SharePoint 2010. Apparently the project template restricts the .NET target framework version which can be selected.
As I was trying to compile a SharePoint 2016 server, once I got the beta templates downloaded for 2016, Visual Studio automatically prompted me to upgrade these projects when trying to open the solution again. Hope this helps someone.
Preview bits for SharePoint 2016 are available here: https://www.microsoft.com/en-us/download/details.aspx?id=49972