Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 14 Next capture
2021 2022 2023
2 captures
12 Jun 22 - 14 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
This question was closed Jan 14 at 10:11 AM by Bunny83 for the following reason:

The question is answered, right answer was accepted

avatar image
4
Question by D3Duck · May 10, 2020 at 12:26 PM · visual studionamespacereference assemblies

Namespace references keep breaking in Visual Studio

Since updating Unity from 2019.2 to 2019.3, I am unable to compile the project code in Visual Studio. It still compiles and runs in the Unity Editor but Visual Studio gives hundreds of missing reference errors ("The type or namespace name 'XXX' could not be found (are you missing a using directive or an assembly reference?)"). This includes files which I wrote, i.e. my own created namespaces.

Nothing I've tried works (see below) except for one thing. If I manually remove the references to all four assemblies in visual studio and re-add them, the solution will compile. But when I then close VS and reopen the same error comes up.

The assemblies are Assembly-CSharp, Assembly-CSharp-Editor, Assembly-CSharp-Editor-firstpass and Assembly-CSharp-firstpass. The normal ones that get created as far as I know.


Why does the reference break each time I restart VS? (Edit: and sometimes when rebuilding the solution without restarting)


Versions

Unity 2019.3.12f1 Personal.

Visual Studio Community 2017 15.9.22.


I've tried:

  • all of these https://stackoverflow.com/questions/29962432/visual-studio-refuses-to-build-project-due-to-missing-assembly-reference-that-is

  • all of these https://stackoverflow.com/questions/450999/are-you-missing-an-assembly-reference-compile-error-visual-studio

  • All of these http://www.codeandyou.com/2017/08/missing-assembly-reference-in-visual.html

  • Removing the .vs folder and all VS files from the Unity project folder and letting the editor regenerate them. Also regenerated manually from within unity
    • Making sure Visual Studio (and the Visual Studio Tools for Unity (which is installed using the Visual Studio installer)) are fully up to date.

    • Updated VS to the latest version

  • Removed VS Code package (I'm not using Code) from Unity, then readded.

  • A number of restarts of Unity and VS in between all the above.


Edit:

From more testing I found that now and then (don't know what triggers it) the reference will break without closing Visual Studio
Comment
Comments Locked · Show 2
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image D3Duck · May 11, 2020 at 11:31 AM 0
Share

Bump. Any ideas on how to possibly fix this would be appreciated

avatar image D3Duck D3Duck · May 13, 2020 at 04:03 AM 0
Share

Bump. Still no solution found. I've deleted a lot of the project but the errors just come up from different scripts. Definitely some issue with VS

5 Replies

  • Sort: 
avatar image
2
Best Answer

Answer by IINovaII · May 13, 2020 at 08:15 AM

It's a bug that happens in Unity 2019.3.12f. Try the newer Unity version 2019.3.13 instead. It's been fixed there. - Nova

Comment
Comments Locked · Show 3 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image D3Duck · May 13, 2020 at 09:27 AM 0
Share

Wow. I hit check for updates in the editor and it told me there were none... But found it in the hub. Downloading it now

avatar image D3Duck · May 13, 2020 at 10:43 AM 0
Share

If I had a million dollars I'd give it to you. I spent 8+ hours trying to figure this out thinking Unity was up to date... It's working now

avatar image IINovaII D3Duck · May 13, 2020 at 12:32 PM 0
Share

I'm happy that I was able to help you. - Nova

avatar image
7

Answer by luixodev · Sep 05, 2020 at 10:24 AM

Same here when I update to Unity 2020.1.4f.4412, any idea?

Comment
Comments Locked · Show 8 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image luixodev · Sep 05, 2020 at 12:02 PM 13
Share

Close VS, then create a new c# file inside unity, double click the file, then all namespaces were restored.

avatar image Ville907 luixodev · Nov 24, 2020 at 10:12 PM 1
Share

This worked for me! Thanks ;)

avatar image alexis78963_unity luixodev · May 07, 2021 at 10:27 AM 0
Share

Awesome thanks!

avatar image ComeSweetDeath luixodev · May 21, 2021 at 04:59 AM 0
Share

Thank you, that was magic

Show more comments
avatar image SkillcraftHD · Jul 28, 2021 at 12:49 PM 0
Share

hey, yeah it works always but my problem is that the problem always occurs again and again randomly

avatar image
3

Answer by metixgosu · Apr 08, 2021 at 12:13 AM

Trigger is if you remove mononehaviour if from any script what is attached on game object in unity, if you want remove mono for any reason in vs just remove it from game object first

Comment
Comments Locked · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
3

Answer by HyronXIII · Sep 01, 2021 at 02:45 PM

Also closing VS and from the Editor clicking Assets -> Open C# Project worked for me, which I assume does something similar to the above mentioned creating a new C# script

Comment
Comments Locked · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
1

Answer by zwang-steven · Oct 12, 2021 at 04:13 PM

Regenerate project files fixes the issue:

Go to Unity 【Edit】 → 【Preferences】 → 【External Tools】 → Click the 【Regenerate project files】 button under "Generate .csproj files for:" → Back to VS

Comment
Comments Locked · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Follow this Question

Answers Answers and Comments

139 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Visual Studio doesn't recognise any Unity namespaces 1 Answer

Adding assembly reference in visual studio causes error in unity 0 Answers

Errors appearing from codes of Unity Libraries 0 Answers

.NET dll seen as native in Unity3D 1 Answer

Visual Studio 2017 namespace cannot be found on installed package 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges