Visual Studio 2013 C# Web Project builds but IDE reports The type or namespace name xxx could not be found error

后端 未结 10 2144
攒了一身酷
攒了一身酷 2020-12-04 16:56

When opening an MVC4 C# web project in Visual Studio 2013, the IDE reports the error \"The type or namespace name \'_\' could not be found (are you missing a using

相关标签:
10条回答
  • 2020-12-04 17:14

    I had same issue when I added a new class file ( e.g. MyClass.cs) and called it in some other C# code places. For some reason VS did not add that new class file to my working project folder (not seen in VS, but seen in Windows File Explorer). And, hence, the compile path for new class file is not included in the compile section of my project file (e.g. MyProject.csproj). So to solve this problem, First, right click on your working project > Add > Existing Item ... > Select your new class > OK.

    Then, check the project file (*.csproj) and make sure a new element is inserted in the compile section such as:

    Finally, rebuild your project and the problem should be solved.

    Another reason for this issue is the project, I had long ago with VS, is my other project was set up with Client Profile as its target framework. So, to solve the issue: Right click your project in VS > Properties > Application tab > make sure Target Framework option is not Client Profile. You should change all projects in your solution to the same framework version AND all of them must not have Client Profile option.

    0 讨论(0)
  • 2020-12-04 17:18

    Same issue, on project reference. I opened the referenced project file (*.csproj) with a text editor and did some cleanup:

    1) reset these properties' values:

    <PublishUrl>publish\</PublishUrl>
    <InstallFrom>Disk</InstallFrom>
    <UpdateEnabled>false</UpdateEnabled>
    <IsWebBootstrapper>false</IsWebBootstrapper>
    <TargetFrameworkProfile />
    

    2) removed dirty platform/configurations:

    <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'x86|AnyCPU'">
    ...
    <PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'x86|x86'">
    ...
    

    Now I can compile without any issue.
    Glad to share it with you! :))

    0 讨论(0)
  • 2020-12-04 17:20

    I have just had this problem and none of the solutions here helped. I fixed mine by doing a repair of Visual Studio (An option when you select to uninstall the program). Hope this helps someone

    0 讨论(0)
  • 2020-12-04 17:22

    I had the same issue.

    It's a VS 2012 solution with different projects.

    Search for all *.suo files and deleted them. Rebuild and reopen Visual Studio.

    0 讨论(0)
  • 2020-12-04 17:28

    My solution, when I encountered the problem with VS 2013 Express edition was to simply unload the offending project and reload. Opening the SUO or Project file and making changes had not affect.

    0 讨论(0)
  • I have the same issue.

    ALthough the project compiles correctly, the code editor shows an error The type or namespace name '_' could not be found (are you missing a using directive or an assembly reference).

    THere is one workaround. Just delete the *.SUO files and re-open the solution. THen for this only Session it works. Unfortunately after closing and reopening the solution the issue is back again. VS 2012 works fine.

    Seems to be a bug in VS 2013....

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