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?
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.
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.
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.
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.
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.
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
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
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With