Press "Enter" to skip to content

Whaddaya Mean “System.Object” Is Not Defined?!?

Every once in a blue moon or two, Visual Studio can get itself into a bizarre state where it’s not resolving the most basic types, like System.Object. You’ve confirmed that you’re referencing the latest version of .NET or .NET Core, you’ve cleaned and rebuilt your solution, and you’ve even rebooted your computer… all to no avail. What gives?!? Visual Studio ends up looking something like this:

Wait… what? “Predefined type ‘System.Object’ is not defined or imported”?!? This is purely a designer thing. If you try to build and/or run the solution, everything works (so long as you don’t have any genuine compiler errors, naturally…)

Well, I’m not entirely sure what is getting copied into the obj and/or bin folders that would specifically cause this, but when you do a Clean (either with dotnet clean, or via the Clean Solution menu command), there are things that aren’t removed that are apparently causing this issue. If someone knows exactly what is doing this, I’d love to know! Either way, the fix is to delete both the obj and bin folders for each project in the solution that is affected by this issue.

Once you do that, you’ll notice that they get dropped back in almost immediately IF you have the solution open in Visual Studio when you delete them. Once the new obj and bin folders are created, Visual Studio should visually clean up, and the System.Object errors will go away. Woot!

Just one of many of Visual Studio’s idiosyncrasies…

6 Comments

  1. Anonymous
    Anonymous November 11, 2022

    Same problem and same solution here

    • Jamie Nordmeyer
      Jamie Nordmeyer February 2, 2023

      Nice!

    • Evan
      Evan February 22, 2023

      No hyperlink, any chance you can repost the solution?

      • Jamie Nordmeyer
        Jamie Nordmeyer March 2, 2023

        Hey Evan, sorry for the delay. What solution are you referring to? The solution is just this post. Am I missing something? I’m happy to provide any other information that you’re looking for… just not sure what it is.

  2. Jesse
    Jesse September 13, 2023

    Also helped me clean up my solution. Much appreciated!

  3. Joel R.
    Joel R. November 4, 2024

    Thank you!

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.