Predefined type 'System.Object' is not defined or imported .net 4.6

后端 未结 12 1200
别那么骄傲
别那么骄傲 2021-02-06 20:02

I\'m using MVC 5 and .net 4.6 to create a web API that my mobile app can connect too.

Whenever I build the project I get hundreds of errors telling me that I need to add

相关标签:
12条回答
  • 2021-02-06 20:39

    This wasted lot of my time. Close the visual studio. Delete the .vs folder and restart visual studio. Everything should work fine.

    Usually this happens when you change branches or merge branches.

    0 讨论(0)
  • 2021-02-06 20:48

    VS2019 solution files were placed under the One drive folder, moving to a different folder outside one drive, fixed this.

    0 讨论(0)
  • 2021-02-06 20:53

    For me, the problem occurred when I added a new project to my solution. I re-built the solution and the errors went away.

    0 讨论(0)
  • 2021-02-06 20:53

    In my case, this is different. First check System.Runtime reference is added to your project or not. If it is added to your project, please follow the below steps.

    1. Open your Reference from your project and select System.Runtime assembly.
    2. Right click on System.Runtime and select property.
    3. Change the value of SpecificVersion from False to True.

    Note : In my Case I am using Visual Studio 2019 and Project Framework Version - 4.6.2

    0 讨论(0)
  • 2021-02-06 20:55

    I'm guessing a bit here but it looks suspicious that you are using the regular System.Data.* stuff for dnx451 but doesn't have anything to make up for it for dnxcore50. Are you targeting the core edition as well or is it just leftovers from project creation? If you want to target the core edition and still use the old System.Data.* stuff you'll need to wrap anything from those assemblies like this.

    #if DNX451
    // Do some DNX451 specific stuff here
    #endif
    

    And the other way around as well.

    #if DNXCORE50
    // Do some DNXCORE50 specific stuff here
    #endif
    

    But if you aren't thinking about supporting this yet I would simply remove dnxcore50 from the framework list and your errors will probably go away.

    0 讨论(0)
  • 2021-02-06 20:59

    I run dotnet restore command on Package manager console and problem solved.

    0 讨论(0)
提交回复
热议问题