Namespace not recognized (even though it is there)

前端 未结 20 1689
终归单人心
终归单人心 2020-11-28 21:27

I am getting this error:

The type or namespace name \'AutoMapper\' could not be found (are you missing a using directive or an assembly reference?)

相关标签:
20条回答
  • 2020-11-28 21:57

    Restarting Visual Studio 2019 - that did it.

    0 讨论(0)
  • 2020-11-28 21:58

    This happened to me in Visual Studio 2019. For me, I was trying to reference another project in my solution. Here are the steps I took in case it helps anyone else:

    1. Ensured the project I wanted to reference was listed under References
    2. Ensured both projects were using the correct version of .NET Framework
    3. Built the project (clicked green "Start" arrow)

    I was confused because I was still getting the error after steps 1 and 2, but building the project seemed to resolve it.

    0 讨论(0)
  • 2020-11-28 21:59

    In my case I got the error only in VS 2015. When opening the project in VS 2017 the error was gone.

    0 讨论(0)
  • 2020-11-28 22:01

    I resolved this issue by right clicking on the folder containing the files and choosing Exclude From Project and then right clicking again and selecting Include In Project (you first have to enable Show All Files to make the excluded folder visible)

    0 讨论(0)
  • 2020-11-28 22:02

    Perhaps the project's type table is in an incorrect state. I would try to remove/add the reference and if that didn't work, create another project, import my code, and see if that works.

    I ran into this while using VS 2005, one would expect MS to have fixed that particular problem by now though..

    0 讨论(0)
  • 2020-11-28 22:03

    This question has already been answered for the original poster, but in case someone encounters this in an MS-Test project:

    from within Visual Studio, click the Test menu -> Test Settings -> Default Processor Architecture and ensure that the architecture matches that of the other assembly that you're referencing. If the other assembly is x64 and your test settings are x86, you may experience the symptoms that the original poster had.

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