Missing Photon Pun assembly reference with Visual Studio Code 1.50.1

6.4k Views Asked by At

I am developing Unity game apps on a PC using C#, using Visual Studio Code as the editor. The apps are targeted at PC and Android. Multiplayer uses Photon Pun 2.

The Unity version is 2019.3.14F1 - I don't want to move forward just yet in case of 'unexpected problems'.

The VS Code version was 1.48.3 - and everything was fine, no compile errors, all code working OK etc.

Stupidly, I took Microsoft's advice to update VSC, and VS Code went to 1.50.1. Result of this is that there are all sorts of errors showing up in VS Code relating to the Photon code. All these errors stem back to the 'using Photon.Pun;' line. It says "the type or namespace name 'Pun' does not exist in the namespace 'Photon' (are you missing an assembly reference?)".

The code however does not come up with any compile errors in the Unity editor itself, and it all runs fine, including the Photon parts. The problem is in VS Code.

I realise this is almost certainly as VS Code problem, not Photon, but I am wondering if anyone has met this before and knows how to fix it?

(This is why I do not want to move from 2019.3.14F1 to 2020.whatever at the moment - you never know what might happen).

6

There are 6 best solutions below

0
On BEST ANSWER

I was wrong.

To-day, the errors are back.

The reason appears to be that in the process of trying to sort this, I installed VS Community Edition 2019 to see if that worked OK (it did). Then went back to VSC, and - that was fine too. Later I uninstalled VS Community Edition 2019 (it is taking about 4GB). It was uninstalling that which brought the errors back into VSC. Reinstalled VS Community Edition 2019, and it is all fine again.

So, VS Community Edition 2019 installs something that VSC needs - but I haven't yet figured out what it is.

UPDATE:

Gave up. Never managed to find out what VSC wanted and wasn't getting. Instead, reinstalled old version of VSC (1.48.2 from code.visualstudio.com/updates) and it is all fine again.

1
On

If still having this problem, all you have to do to fix it is by going to Package manager and install "visual studio editor package"

windows>Package Manager> All Packages /or Unity Registry (depeding on your unity version) search of visual studio editor

if it's already installed delete it and reinstall.

0
On

Uninstall the Visual studio community and re-install with latest VSC 2022. It will fix the issue

0
On

Got it FIXED! Solution (it was a Unity issue): In Unity, goto Edit > Preferences > External Tools > External Script Editor, and point it to Visual Studio.. Why this was so hard to find, I have no idea. But now my Photon solutions and namespaces properly transfer from Unity to Visual Studio. Hooah!

Also moved the script to where the photon scripts are

0
On

Tried rebuilding project files, swapping to a different editor (VS Community Edition 2019 - that was fine), but no difference - VSC persisted with the errors. Rest of intellisense working OK.

In the end, totally uninstalled VSC and reinstalled, and that sorted it out. No idea what the actual fault was.

3
On

I had the same problem. Installing different versions of VS Code / VS Community Edition didn't fix anything for me, but this did:

With the project open in VS Code, find all occurrences of

<ReferenceOutputAssembly>false</ReferenceOutputAssembly>

in *.csproj files, and replace them with

<ReferenceOutputAssembly>true</ReferenceOutputAssembly>