Ошибка компилятора cs0234

Permalink

Cannot retrieve contributors at this time

description title ms.date f1_keywords helpviewer_keywords ms.assetid

Compiler Error CS0234

Compiler Error CS0234

07/20/2015

CS0234

CS0234

413774cc-b63e-472b-8fe7-cf23ca970a5f

Compiler Error CS0234

The type or namespace name ‘name’ does not exist in the namespace ‘namespace’ (are you missing an assembly reference?)

A type was expected. Possible causes for this error include the following:

  • An assembly that contains the definition of a type was not referenced in the compilation; use References (Import Metadata) to specify the assembly

  • You passed a variable name to the typeof operator.

  • You tried to reference an assembly that is not part of your .NET target framework moniker (TFM). For more information, see Troubleshooting .NET Targeting Errors.

If you see this error after moving code from one development machine to another, make sure that the project on the new machine has the correct references, and that the versions of the assemblies are the same as on the old machine. You can also use the Object Browser to inspect an assembly and verify whether it contains the types that you expect it to contain.

The following sample generates CS0234:

// CS0234.cs  
public class C  
{  
   public static void Main()  
   {  
      System.DateTime x = new System.DateTim();   // CS0234  
      // try the following line instead  
      // System.DateTime x = new System.DateTime();  
   }  
}  

We’re working on a WPF project using Visual Studio 2015. We’ve got a folder in the project named Assets. It shows up fine in VS 2015. The files in it show up fine in the Solution Explorer. But when we build it, VS 2015 complains with the following error:

Error CS0234 The type or namespace name ‘Assets’ does not exist in
the namespace ‘CoreFramework’ (are you missing an assembly
reference?)

(CoreFramework is the name of our solution and the project that Assets is in.)

I don’t get how the folder is there in CoreFramework, but when building it, VS 2015 just doesn’t see it. I’ve tried cleaning both the project and the solution in VS 2015, but it doesn’t help at all. The same errors keep popping up. And they popup in our nightly builds as well.

So what is causing VS 2015 to simultaneously see a folder within a project and not see that same folder in the project?

StayOnTarget's user avatar

StayOnTarget

11.5k10 gold badges50 silver badges78 bronze badges

asked Feb 15, 2016 at 22:01

Rod's user avatar

17

In this case what I had to do was to delete everything in the obj folder beneath our project main folder. The solution’s name is CoreFramework and the main project’s name is also CoreFramework. So what I did was go to CoreFrameworkCoreFrameworkobj and deleted everything there. Since at this point we’re only dealing with a debug version, the only thing there was the Debug folder and all temporary files and folders under that. Once I did that, then rebuilding the solution re-created all of the temporary files and folders, without the problem I was having with the Assets folder. It built fine.

YMMV

answered Feb 16, 2016 at 18:47

Rod's user avatar

RodRod

4,00912 gold badges57 silver badges79 bronze badges

Check the .Net-Framework Versions of both Projects. If the referenced project has a higher .Net-Framework Version than the referencing project this error might occur.

ProjectName -> Properties -> Application -> Target framework

answered Jun 25, 2021 at 12:44

Findas's user avatar

I had the same issue after I manually copied the referenced DLL file.
I solved it by displaying the reference properties in the Solution explorer then changing the Specific version setting from True to False and finally changing it back to True.
I rebuild and… it works just fine. Do not ask me why…

Note : I had to do the same for each project which had the CS0234 error message

PS : in my case Visual studio version is 16.1.6

answered Dec 30, 2019 at 13:25

leguminator's user avatar

I have some missing assemblies in my PC, and don’t have any idea how to fix it.

When I create a new ASP.NET MVC 4 internet application from template (using VS 2012) everything works fine. As soon as I try to integrate Web API controller I get a missing assembly reference error. For example, when I create application using ASP.NET 4 Web API default template and click «API» on the interface I get Compilation error:

Compiler Error Message: CS0234: The type or namespace name 'Description' does not exist in the namespace 'System.Web.Http' (are you missing an assembly reference?)

I have checked the assembly and everything seems to be fine. It’s in version 4.0. I have .NET framework 4.5 installed on my PC. Where should I look for the reason of the issue?

asked Nov 3, 2014 at 22:38

Bartosz's user avatar

BartoszBartosz

4,48211 gold badges43 silver badges68 bronze badges

4

I saw this same error code (different missing reference) when compiling a PCL using msbuild but not when building via Visual Studio:

error CS0234: The type or namespace name 'Storage' does not exist in the namespace 'Windows' (are you missing an assembly reference?)

In my case it was caused by a ‘using Windows.Storage;’ statement that was not actually referenced by any code in the file. I removed the line and the error was fixed.

answered Jul 23, 2015 at 22:40

Andy Joiner's user avatar

Andy JoinerAndy Joiner

5,8423 gold badges45 silver badges72 bronze badges

User-1330485181 posted

Hi All,

Summary of the problem I am having:

I am building ASP.NET C# Web form using Visual Studio 2019 with Target framework 4.72,  but I found error like this below

Error I am receiving:

<

Compilation Error

Description:
An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: CS0234: The type or namespace name ‘Linq’ does not exist in the namespace ‘System.Data’ (are you missing an assembly reference?)

Source Error:

Line 12: namespace WebApplication1.App_Code
Line 13: {
Line 14: 	using System.Data.Linq;
Line 15: 	using System.Data.Linq.Mapping;
Line 16: 	using System.Data;


Source File: D:GL-ProjectWebApplication1WebApplication1App_CodeDataClassesGL.designer.cs   
Line: 14

Show Detailed Compiler Output:

Show Complete Compilation Source:


Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.8.4075.0
>

My code:

<

#pragma warning disable 1591
//——————————————————————————
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//——————————————————————————

namespace WebApplication1.App_Code
{
using System.Data.Linq;
using System.Data.Linq.Mapping;
using System.Data;
using System.Collections.Generic;
using System.Reflection;
using System.Linq;
using System.Linq.Expressions;
using System.ComponentModel;
using System;

public partial class DataClassesGLDataContext : System.Data.Linq.DataContext
{

private static System.Data.Linq.Mapping.MappingSource mappingSource = new AttributeMappingSource();

#region Extensibility Method Definitions
partial void OnCreated();
#endregion

public DataClassesGLDataContext(string connection) :
base(connection, mappingSource)
{
OnCreated();
}

public DataClassesGLDataContext(System.Data.IDbConnection connection) :
base(connection, mappingSource)
{
OnCreated();
}

public DataClassesGLDataContext(string connection, System.Data.Linq.Mapping.MappingSource mappingSource) :

base(connection, mappingSource)
{
OnCreated();
}

public DataClassesGLDataContext(System.Data.IDbConnection connection, System.Data.Linq.Mapping.MappingSource mappingSource) :

base(connection, mappingSource)
{
OnCreated();
}
}
}
#pragma warning restore 1591

>

Does the LinqToSQL still be able to used on dot Net Framework 4.72 or higher ? 

Regards,

Sentoso

C# Compiler Error

CS0234 – The type or namespace name ‘name’ does not exist in the namespace ‘namespace’ (are you missing an assembly reference?)

Reason for the Error

You will usually see this error in your C# program when you try to reference an assembly that is not part of your project or you have referred to an class by specifying the namespace and the class is misspelt or doesnot exist.

For example, try to compile the below code snippet.

namespace DeveloperPubNamespace
{
    public class Employee
    {
        public string SurName { get; set; }
    }
    class Program
    {
        public static void Main()
        {
            DeveloperPubNamespace.Employe emp = new DeveloperPubNamespace.Employe();
        }
    }
}

This program will result with the C# error code CS0234 because the DeveloperPubNamespace doesnot have the class Employe.

Error CS0234 The type or namespace name ‘Employe’ does not exist in the namespace ‘DeveloperPubNamespace’ (are you missing an assembly reference?) DeveloperPublish C:UsersSenthilsourcereposConsoleApp3ConsoleApp3Program.cs 11 Active

Solution

To fix the error code CS0234 in C#, just ensure that your project has correct references and the class that you are trying to access via the namespace exists. Try using the Object Browser to verify if the assembly contains the type that you are using.

namespace DeveloperPubNamespace
{
    public class Employee
    {
        public string SurName { get; set; }
    }
    class Program
    {
        public static void Main()
        {
            DeveloperPubNamespace.Employee emp = new DeveloperPubNamespace.Employee();
        }
    }
}

Понравилась статья? Поделить с друзьями:
  • Ошибка компилятора c2563
  • Ошибка компилятора c2535
  • Ошибка компилятора c2398
  • Ошибка компилятора c2371
  • Ошибка компилятора c2338