One of the things I was going to mention was whether the file was set to compile or not, but I don’t think that would have been the issue, I think you have actually described the issue yourself.
To answer your question, yes, I leave Visual Studio open, I have the full package and launching that every time would create so much waiting time I would never get anything done… lol…
So, what’s happening is that you have the project open in two places. Visual Studio is clever enough to note that something has changed, for example, when you have it open, flick back to Unity and add a new script. Instead of choosing “no”, choose “yes”, then your changes within Unity (in this case the addition of the new script) will be brought into Visual Studio.
I would put a very small amount of money on this is what happened. You added the script in Unity, had Visual Studio open, chose “no”, the project within Visual Studio then never saw the Utility.cs file and as such had no idea what Layer was.
If you want to be on the safe side, just make sure you have all of your files in Visual Studio saved before flicking back and forth and making more changes. I’ve not personally run into any problems like this.
Glad you have got it resolved anyway. If you’re really bored, you could probably try the steps above and see if a similar issue can be reproduced… I could then win that tiny amount of money