Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Compiler Error Message: CS0246: when I renamed my project

I renamed my project and it would compile before but when I made some changes it stopped working for some reason

the error is

Compiler Error Message: CS0246: The type or namespace name 'Lab4' could not be found (are you missing a using directive or an assembly reference?)

I made a new project from the template of Lab4 and renamed it to lab5 following the steps here

http://petermcintyre.com/topics/using-an-app-as-a-template-asp-net-mvc/

I found the source file

Line 28:     using Lab4;
Line 29:     
Line 30:     

Source File: c:\Users\Albert\AppData\Local\Temp\Temporary ASP.NET Files\root\4b806faf\de1f1e7\App_Web_index.cshtml.a8d08dba.c_hu0onk.0.cs    Line: 28  

of that but when I try to change the using Lab4 to lab5 and recompile it, the same error happens and that file gets deleted and a new one gets made with the same Lab4 issue.

Does anyone know the answer?

like image 302
user2981393 Avatar asked Feb 17 '14 23:02

user2981393


People also ask

How do I fix compiler error cs0246?

First, you need a reference to the assembly that contains the definition for the DataSet type. Second, you need a using directive for the namespace where DataSet is located. For example, because DataSet is located in the System.

Why am I getting error cs0246 the type or namespace name could not be found?

This problem typically comes when: You do not have class with that name in your project. You add the class later on and run the project without compiling. You have the class but you do not specify the namespace via Imports or using keyword.

How do I rename a file in Csproj?

Right-click on the project name & click reload the project. Then rename the project name as highlighted below & save. It will automatically rename the . csproj file.

What is compiler error cs0246?

A type or namespace that is used in the program was not found. You might have forgotten to reference ( -reference) the assembly that contains the type, or you might not have added the required using directive. Or, there might be an issue with the assembly you are trying to reference. The following situations cause compiler error CS0246.

Why am I getting a namespace name error cs0246?

If the error is for a namespace name, did you add a reference (References) to the assembly that contains the namespace? For example, your code might contain the directive using Accessibility. However, if your project does not reference the assembly Accessibility.dll, error CS0246 is reported.

Why is my compiler not finding the correct name of a type?

Without the correct name, the compiler cannot find the definition for the type or namespace. This often occurs because the casing used in the name of the type is not correct. For example, Dataset ds; generates CS0246 because the s in Dataset must be capitalized. If the error is for a namespace name, did you add a reference to the assembly that

What is cs0234 error message?

Compiler Error Message: CS0234: The type or namespace name 'OracleClient' does not exist in the namespace 'System.Data' (are you missing an assembly reference?) Please Sign up or sign in to vote. I run 'Build' on my project without any error. Then I run Debugging, and got


2 Answers

When Visual Studio creates your project, it automatically adds its original namespace to \Views\web.config:

<system.web.webPages.razor>
    <pages pageBaseType="System.Web.Mvc.WebViewPage">
        <namespaces>
            ...
            ...
            ...
            <add namespace="OriginalProjectNamespace" />
        </namespaces>
    </pages>
</system.web.webPages.razor>

After renaming the project or changing its default namespace you must manually change it in this file.

like image 158
Caspian Canuck Avatar answered Oct 21 '22 20:10

Caspian Canuck


It's probably a reference/path that VS hasn't updated when you renamed. It's quick and dirty but if you run a Grep against the solution folder for the old project name and replace it with the new one and then re-open and compile in VS it should solve your problem.

like image 3
Jay Wilde Avatar answered Oct 21 '22 19:10

Jay Wilde