changing the .net framework to 4.6

I found in the editor I could change the api compatibility level and the scripting runtime version to .net4.6. However in the actual solution (VS2015) my main project is still 3.5. Never fear I changed the project properties to target 4.6. I had to edit the csproj file to accomplish this as unity has never allowed me to right click > properties of a project. Anyhow upon reloading it says “Hey this project wants to be 4.6 but you only have 4.5.2 available on the machine (lies i have all the way up to 4.6.2)” It does mention a .net 4.6 subset profile for unity but search as I want there is no .net framework that goes by this name that I can find.

I’d really like to use 4.6 in my project as i have plugins that target 4.6 that i’d rather not rewrite.

I think i resolved this by changing the to 6 in the csproj file. It is compiling and letting me use things like null conditionals. The game appears to run fine.

^^ I lied it doesn’t work. Once you save something in the editor it changes the projects target version back to 3.5 and langversion to 4.

Anyone know if this is possible to do?

Install this (ver. 3.1):

Also works with VS 2017.

I have the same problem. The preview doc linked from a pinned post in this forum says:

So is this a bug? Why are the settings not changed automatically, but instead even overwritten with the old language version?

Could this be the reason, why Unity doesn’t work with VS Code after changing to .Net 4.6?
If so, has anyone found a workaround?

1 Like

Please try Andrzej’s suggestion and install VSTU 3.1. If it still doesn’t work, please file a bug report and reply in here with the case #.

Some earlier VSTU versions overwrite the project files every time you compile and switch the version automatically to .NET 3.5, as well as intercepting the window that lets you change the project settings and force-closing it just to stop you from being able to even select .NET 4. They were pretty adamant a year ago about how this was a great “feature”. :wink: You absolutely need to download the newest version where they’ve removed that again, and you can change the .NET version.

I can confirm that I fixed issue after upgrading to VSTU v3.1 (2017.b4 installed)

@makeshiftwings interesting comment about ability to view project properties as mine still intercepts windows even after upgrade which is annoying! Would love to have that ability back, it might be a great feature for beginners but annoying for the rest of us…

Thank you all! I can also confirm that it works with the VSTU 3.1 in Unity 2017.1.0b5. Maybe it would be a good idea to update the preview docs to mention this requirement.

I’ve updated the document it indicate that VSTU 3.1 should be used. Sorry for the confusion.

2 Likes