error CS0246 has ruined my project

Hi everyone, I really hope you can help me.
I’m making a 2d platformer/fighter. It was going well, until I updated VS. The update caused 27.937 errors to appear, as far as I can see all of them are related to the cs0246 error. I’ve since tried updated Unity to a newer version as well as VS, but to no avail. I know other people have had the same error and I’ve tried many potential fixes, but so far they haven’t worked.
Any advice would be welcome at this point.
Thank you in advance,

This seems more like a Visual Studio issue than a Unity issue, but please list what you have tried already. Also, please inform us whether it’s Unity or Visual Studio that produces the error, or both. And finally, software versions would also be helpful.

Can you post some screenshots of the error and also the error caused in the program code please?

Okay, so for starters, I think you are right in presuming it’s a Visual Studio problem. The only error I receive in Unity is the “All compilers have to be fixed before you enter playmode”, no console messages.

I work on a Mac

Unity is currently Version 2019.1.7f1 Personal
Visual Studio is currently 8.1.1 (build 27)

Unfortunately I can’t remember which versions I upgraded from.

I’ve tried:

  • clean all, build all in VS
  • deleting the Library folder
  • deleting the Assembly-CSharp.csproj file
  • Reimport all in Unity
  • I’ve tried using a backup of the file.

I’m sure I’ve tried other fixes, but I can’t remember them off the top of my head.

If I clean all, the 27.000 errors are reduced to one

As soon as I try to debug the code, the many errors reappear.

If you updated visual studio, did you also update the visual studio tools for unity plugin? That could be the problem, if you didn’t.

1 Like

I guess I didn’t, I’ve never even heard of that, that’s embarrassing. How do I do that?

Can you post the complete script, in Code tags? It’s hard to tell from just a screenshot, but you could just be missing a curly brace somewhere.

As for Visual Studio Tools for Unity, that’s usually installed via the Visual Studio Installer program, but I’m not sure if it’s different for Mac: Visual Studio Tools for Unity | Microsoft Learn

From the Visual Studio installer, there is a Mobile and Gaming section. Pick the Unity Development option and install it. When that’s done, make sure that you project is targeting the right install of VS in Edit->Preferences->External Tools->External Script Editor. You might have to restart Unity and/or your computer to make it work.

As far as I can see it’s all of my scripts that are malfunctioning and they also worked perfectly before the update, so I’m fairly positive it’s not a missing bracket. Though it would be a nice, simple solution!

I don’t think it’s a problem with VS tools for Unity, it’s enabled correctly as far as I can see.

It may be as simple as clearing out the solution files and letting unity rebuild them. I don’t know what you have tried, so it’s hard to say what may work for you. And unfortunately, I’m not as familiar with macs.

Hopefully you do have a repo for your project in case you need to restore it.

I agree that does not seem to be a bracket issue, but more a IDE issue. Very frustrating, because you know the code is correct and the issue is often not easy to find.

I did run in to VS not enabling IntelliSense before, but that was solved by selecting VS as editor in Unity. (So the project file is launched instead of just the .cs file.)

In this case it doesn’t seem to recognize the Unity namespaces, but I also see errors with void, bool and true. So it seems that VS isn’t even recognizing the most basic namespaces correctly. I’d say, deinstall VS and reinstall it.

Try to close Unity and VS, and delete every single .csproj file and .sln in your project folder. Then open Unity and see if you can enter play mode.

Thank you for your suggestions!
I tried reinstalling VS and deleting every .csproj and .sln file and unfortunately it didn’t work.
Any other ideas?

I found the solution!
After mailing my project to one of the VS microsoft devs, it turned out that a recent update didn’t recognize “:” in the name of the project, and my project had a “:” in it’s title. Changing the title fixed the issue immediately. So a very simple solution to a serious issue.