Compiler error cs0234

This repository contains .NET Documentation. Contribute to dotnet/docs development by creating an account on GitHub.

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

11k10 gold badges49 silver badges75 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

3,92711 gold badges55 silver badges78 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

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();
        }
    }
}

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

23 / 10 / 1

Регистрация: 08.10.2015

Сообщений: 382

1

07.08.2018, 10:44. Показов 4132. Ответов 6


Здравствуйте!
При добавлении строки кода:»using System.Text.RegularExpressions;», в проект, возникает ошибка:
CS0234 Тип или имя пространства имен «RegularExpressions» не существует в пространстве имен «System.Text» (возможно, отсутствует ссылка на сборку).
Подскажите, пожалуйста, как это исправить?

__________________
Помощь в написании контрольных, курсовых и дипломных работ, диссертаций здесь



0



910 / 795 / 329

Регистрация: 08.02.2014

Сообщений: 2,391

07.08.2018, 11:03

2

1) Версия .net какая у Вас стоит?
2) System.dll подключена в проекте?



0



23 / 10 / 1

Регистрация: 08.10.2015

Сообщений: 382

07.08.2018, 11:14

 [ТС]

3

SeIZVeIZ,
1) VS 2015 4.5.2
2) Как её подключить?



0



910 / 795 / 329

Регистрация: 08.02.2014

Сообщений: 2,391

07.08.2018, 11:19

4

Лучший ответ Сообщение было отмечено HitGirl как решение

Решение

В Solution Explorer(Обозреватель решений), есть папка Reference(ссылки), нажимаете правой кнопкой -> Добавить -> Там Assemblies (не знаю как в русской локализации будет там может Сборки) -> и в списке выбираете System



1



0 / 0 / 0

Регистрация: 17.07.2021

Сообщений: 9

20.07.2021, 19:02

5

Нужно, чтобы работала команда using Systeam.Windows.Froms
Но нужно, как я понял подключать какие-то ссылки или сборки, пишут как это сделать и в конце выбирайте нужны файл, а какой нужен то??? и где его искать



0



Эксперт по электронике

1977 / 1273 / 428

Регистрация: 04.09.2018

Сообщений: 4,590

Записей в блоге: 2

20.07.2021, 19:09

6

Код покажите свой. Ошибка CS0234 может возникать и в случае синтаксической ошибки.



0



0 / 0 / 0

Регистрация: 17.07.2021

Сообщений: 9

20.07.2021, 19:42

7

Ошибkа — CS0234, что-то попытался добавить , теперь ошибка еще эта — MSB3290
мне нужно , чтобы работало using System.Windows.Forms, но как я понял сначала нужна ссылка на сборку (Где эту ссылку искать я не знаю)



0



Submitted by alexc on Thu, 12/23/2021 — 09:08

Note: The following information applies to RTI Connext DDS 6.1.0 — 6.1.0.3.

Many code examples for the Connext DDS C# API, including those generated by rtiddsgen, use the .NET package System.CommandLine to parse the options passed to the application.

A recently released version of System.CommandLine included breaking changes. The Connext examples did not lock the required System.CommandLine version and therefore may automatically download the latest version, which causes the following compilation error:

error CS0234: The type or namespace name 'CommandHandler' does not exist in the namespace 'System.CommandLine.Invocation'


How to fix this error

To fix this error, simply update the example .csproj file to use a previous System.CommandLine version.

You can do this using the dotnet CLI:

dotnet add package System.CommandLine --version 2.0.0-beta1.21308.1

Or by editing the .csproj files and replacing: 

<PackageReference Include="System.CommandLine" Version="2.0.0-*" />

With:

<PackageReference Include="System.CommandLine" Version="2.0.0-beta1.21308.1" />

Note that this package is only used to parse the options for the example. Once you write your own application you may no need to use this package anymore.

Понравилась статья? Поделить с друзьями:
  • Compiler error cs0123
  • Compiler error cs0122
  • Compiler error cs0121
  • Compiler error cs0120
  • Compiler error cs0119