Using namespace system error

Ошибка компилятора CS0246 Не удалось найти имя типа или пространства имен «тип/пространство_имен» (пропущена директива using или ссылка на сборку?) Не удалось найти тип или пространство имен, которое используется в программе. Возможно, вы забыли сослаться (References) на сборку, содержащую этот тип, или не добавили необходимую директиву using. Также возможно, что возникла проблема со сборкой, на […]

Содержание

  1. Ошибка компилятора CS0246
  2. Compiler Error CS0246
  3. Using namespace system error
  4. Лучший отвечающий
  5. Вопрос
  6. Ответы
  7. Все ответы
  8. Using namespace system error
  9. Answered by:
  10. Question
  11. Answers
  12. All replies

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

Не удалось найти имя типа или пространства имен «тип/пространство_имен» (пропущена директива using или ссылка на сборку?)

Не удалось найти тип или пространство имен, которое используется в программе. Возможно, вы забыли сослаться (References) на сборку, содержащую этот тип, или не добавили необходимую директиву using. Также возможно, что возникла проблема со сборкой, на которую вы пытаетесь ссылаться.

В следующих ситуациях возникает ошибка компилятора CS0246.

Допущена ошибка в имени типа или пространства имен? Без правильного имени компилятор не сможет найти определение типа или пространства имен. Это часто происходит из-за использования неверного регистра в имени типа. Например, Dataset ds; приводит к ошибке CS0246, поскольку буква s в Dataset должна быть прописной.

Если ошибка связана с именем пространства имен, добавили ли вы ссылку (References) на сборку, содержащую это пространство имен? Например, код может содержать директиву using Accessibility . Однако если ваш проект не ссылается на сборку Accessibility.dll, возникает ошибка CS0246. Дополнительные сведения см. в разделе Управление ссылками в проекте.

Если ошибка связана с именем типа, включили ли вы необходимую директиву using или полное имя типа? Рассмотрим следующее объявление: DataSet ds . Для использования типа DataSet необходимо следующее. Во-первых, нужна ссылка на сборку, содержащую определение типа DataSet . Во-вторых, требуется директива using для пространства имен, где находится DataSet . Например, поскольку DataSet находится в пространстве имен System.Data , в начале кода требуется указать следующую директиву: using System.Data .

Директива using не является обязательной. Однако если эта директива не используется, вы должны указать полное имя типа DataSet при ссылке на него. Полное имя означает, что при каждой ссылке на тип в коде вы должны указывать этот тип вместе с его пространством имен. Если в предыдущем примере не указывать директиву using , то необходимо писать System.Data.DataSet ds вместо ds для объявления DataSet ds .

Вы использовали переменную или другой элемент языка там, где ожидался тип? Например, если в операторе is вы используете объект Type вместо фактического типа, возникнет ошибка CS0246.

Возможно, вы ссылаетесь на сборку, которая создана на платформе более поздней версии, чем версия целевой платформы программы? Или вы ссылались на проект, нацеленный на платформу более поздней версии, чем у целевой платформы программы? Например, возможно, вы работаете над проектом с целевой платформой .NET Framework 4.6.1, но используете тип из проекта с целевой платформой .NET Framework 4.7.1. В этом случае возникает ошибка CS0246.

Включены ли все упоминаемые проекты в выбранную конфигурацию сборки и платформу? Используйте Configuration Manager Visual Studio, чтобы убедиться, что все проекты, на которые имеются ссылки, помечены для сборки с выбранной конфигурацией и платформой.

Вы использовали директиву using псевдоним без указания полного имени типа? Директива » using псевдоним» не использует директивы using в файле исходного кода для разрешения типов. В следующем примере возникает ошибка CS0246, поскольку не указано полное имя типа List . Директива using для System.Collections.Generic не предотвращает эту ошибку.

При появлении этой ошибки в коде, который ранее работал, сначала найдите отсутствующие или неразрешенные ссылки в обозревателе решений. Требуется ли переустановить пакет NuGet? Сведения о том, как система сборки ищет ссылки, см. в записи блога Разрешение ссылок на файлы в Team Build. Если все ссылки выглядят правильными, просмотрите свой журнал системы управления версиями, чтобы найти изменения в CSPROJ-файле или в файле локального источника.

Если все еще не удалось успешно получить доступ к ссылке, с помощью обозревателя объектов проверьте сборку, которая должна содержать это пространство имен, и убедитесь, что оно существует. Если вы проверили в обозревателе объектов, что сборка содержит это пространство имен, попробуйте удалить для этого пространства директиву using и посмотрите, что еще не будет работать. Корень проблемы может быть в каком-либо другом типе в другой сборке.

В следующем примере возникает ошибка CS0246 из-за отсутствия необходимой директивы using .

В следующем примере возникает ошибка CS0246, поскольку там, где ожидался фактический тип, использовался объект типа Type .

Источник

Compiler Error CS0246

The type or namespace name ‘type/namespace’ could not be found (are you missing a using directive or an assembly reference?)

A type or namespace that is used in the program was not found. You might have forgotten to reference (References) 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.

Did you misspell the name of the type or namespace? 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 (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. For more information, see Managing references in a project

If the error is for a type name, did you include the proper using directive, or, alternatively, fully qualify the name of the type? Consider the following declaration: DataSet ds . To use the DataSet type, you need two things. 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.Data namespace, you need the following directive at the beginning of your code: using System.Data .

The using directive is not required. However, if you omit the directive, you must fully qualify the DataSet type when referring to it. Full qualification means that you specify both the namespace and the type each time you refer to the type in your code. If you omit the using directive in the previous example, you must write System.Data.DataSet ds to declare ds instead of DataSet ds .

Did you use a variable or some other language element where a type was expected? For example, in an is statement, if you use a Type object instead of an actual type, you get error CS0246.

Did you reference the assembly that was built against a higher framework version than the target framework of the program? Or did you reference the project that is targeting a higher framework version than the target framework of the program? For example, you work on the project that is targeting .NET Framework 4.6.1 and use the type from the project that is targeting .NET Framework 4.7.1. Then you get error CS0246.

Are all referenced projects included in the selected build configuration and platform? Use the Visual Studio Configuration Manager to make sure all referenced projects are marked to be built with the selected configuration and platform.

Did you use a using alias directive without fully qualifying the type name? A using alias directive does not use the using directives in the source code file to resolve types. The following example generates CS0246 because the type List is not fully qualified. The using directive for System.Collections.Generic does not prevent the error.

If you get this error in code that was previously working, first look for missing or unresolved references in Solution Explorer. Do you need to reinstall a NuGet package? For information about how the build system searches for references, see Resolving file references in team build. If all references seem to be correct, look in your source control history to see what has changed in your .csproj file and/or your local source file.

If you haven’t successfully accessed the reference yet, use the Object Browser to inspect the assembly that is supposed to contain this namespace and verify that the namespace is present. If you verify with Object Browser that the assembly contains the namespace, try removing the using directive for the namespace and see what else breaks. The root problem may be with some other type in another assembly.

The following example generates CS0246 because a necessary using directive is missing.

The following example causes CS0246 because an object of type Type was used where an actual type was expected.

Источник

Using namespace system error

Лучший отвечающий

Вопрос

создаю пустой проект с++ и хочу подключить пространство имен System::Windows::Forms;

Ответы

Если сообщение помогло Вам, пожалуйста, не забудьте отметить его как ответ данной темы. Удачи в программировании!

  • Предложено в качестве ответа Yatajga Moderator 23 октября 2014 г. 6:12
  • Помечено в качестве ответа Magals 23 октября 2014 г. 7:48

Все ответы

Сделаем содержимое сообщества лучше, вместе!

Насколько я знаю проект Win Forms для C++/CLI не поддерживается новых студиях.

Сделаем содержимое сообщества лучше, вместе!

Сделаем содержимое сообщества лучше, вместе!

Убедитесь, что нужные сборки у вас в проекте включены, т.е. ссылки на них.

Сделаем содержимое сообщества лучше, вместе!

Сделаем содержимое сообщества лучше, вместе!

Посмотрите в свойствах проекта, насколько помнится там должны быть.

Сделаем содержимое сообщества лучше, вместе!

Если сообщение помогло Вам, пожалуйста, не забудьте отметить его как ответ данной темы. Удачи в программировании!

  • Предложено в качестве ответа Yatajga Moderator 23 октября 2014 г. 6:12
  • Помечено в качестве ответа Magals 23 октября 2014 г. 7:48

Я уже отвечал однажды на подобный вопрос. Посмотрите здесь. Проблема в том, что мастер создания форм уже добавил директивы using в заголовочном файле внутрь пространства имен Вашего проекта. Вам не нужно их писать в cpp-файле, нужно лишь «открыть» пространство проекта и все.

Если сообщение помогло Вам, пожалуйста, не забудьте отметить его как ответ данной темы. Удачи в программировании!

Источник

Using namespace system error

This forum has migrated to Microsoft Q&A. Visit Microsoft Q&A to post new questions.

Answered by:

Question

I copied the example from Visual studio C++ examples for DateTime

but it compiles with error:

error C2871: ‘System’ : a namespace with this name does not exist

after comment out the DateTime declaration, turns out this sentence is not accepted by the compiler:

using namespace System;

why this sentence is not OK? any help?

Answers

Thanks a lot, I got the answer when you were typing it.

but thanks a lot for helping!

I really hope MS should enable this option by default.

while I’m compiling with the Common Language Runtime Support(clr) I get following error:

Command line error D8016 : ‘/MTd’ and ‘/clr’ command-line options are incompatible

Anyone knows why?

Hi all,
Although I compile my project with Common Language Runtime (/clr) but I still got these problems:
error C2653: ‘System’ : is not a class or namespace name
error C2871: ‘Forms’ : a namespace with this name does not exist

Please help me out.
Thanks a million.
Cheers,
ntquang

I am trying the save a bitmap into a file and I am using the Save function from the Bitmap pointer bmpIn. I have the following code:
The compiler gives me this error:
What’s the problem?

You should have posted this in a new thread, not attach it
to a thread which is 2-3 years old and which has already
been marked as answered.

Not enough context for me to give an educated guess as to
what’s wrong.

What compiler and version are you using?

What type of project are you building?

Is it a Windows Forms app?

looks reasonable, if used in a WF program.

Assuming VC++ 2008, if you create a new Windows Forms project,
add one button to the form, and in the button’s Click event
code put this code:

Источник

  • Remove From My Forums
  • Question

  • // Include Mil library
    #include <mil.h>
    // Include standard libraries
    #include <string>
    #include <stdio.h>
    #include <windows.h>
    
    // Namespace
    using namespace std;
    using namespace System;
    
    // Settings
    const int bufLength = 10;
    string picName = "pic_";
    string picFolder = "Pics";

    If I’m try to insert «#using namespace System» I get an error «‘System’ : a namespace with this name does not exist». I’m using Visual Studio 2008 and I’m programming in C++. Why do I get this error?

Answers

  • Namespace System is for C++/CLI, not C++. If you want to use C++/CLI, enable a
    /clr variant.

    • Proposed as answer by

      Tuesday, December 7, 2010 6:28 AM

    • Marked as answer by
      Jesse Jiang
      Thursday, December 9, 2010 2:44 AM

  • you can use it only if /clr is enabled.

    you can try creating a new project of type which supports /clr… say for eg. windows form application supports /clr..

    following link might be useful, just checkout once..

    http://msdn.microsoft.com/en-us/library/k8d11d4s.aspx

    ==================================================
    if you feel that any reply as the answer please mark as answer by clicking the
    link below..so that others having same problem, will know whats the solution..
    if you feel any reply was helpful to you please click on left pane as «helpful».
    ==================================================


    — Jaki Chan

    • Proposed as answer by
      Jesse Jiang
      Tuesday, December 7, 2010 6:28 AM
    • Marked as answer by
      Jesse Jiang
      Thursday, December 9, 2010 2:44 AM

description title ms.date f1_keywords helpviewer_keywords ms.assetid

Compiler Error CS0246

Compiler Error CS0246

01/23/2018

CS0246

CS0246

4948fae2-2cc0-4ce4-b98c-ea69a8120b71

Compiler Error CS0246

The type or namespace name ‘type/namespace’ could not be found (are you missing a using directive or an assembly reference?)

A type or namespace that is used in the program was not found. You might have forgotten to reference (References) 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.

  • Did you misspell the name of the type or namespace? 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 (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. For more information, see Managing references in a project

  • If the error is for a type name, did you include the proper using directive, or, alternatively, fully qualify the name of the type? Consider the following declaration: DataSet ds. To use the DataSet type, you need two things. 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.Data namespace, you need the following directive at the beginning of your code: using System.Data.

    The using directive is not required. However, if you omit the directive, you must fully qualify the DataSet type when referring to it. Full qualification means that you specify both the namespace and the type each time you refer to the type in your code. If you omit the using directive in the previous example, you must write System.Data.DataSet ds to declare ds instead of DataSet ds.

  • Did you use a variable or some other language element where a type was expected? For example, in an is statement, if you use a Type object instead of an actual type, you get error CS0246.

  • Did you reference the assembly that was built against a higher framework version than the target framework of the program? Or did you reference the project that is targeting a higher framework version than the target framework of the program? For example, you work on the project that is targeting .NET Framework 4.6.1 and use the type from the project that is targeting .NET Framework 4.7.1. Then you get error CS0246.

  • Are all referenced projects included in the selected build configuration and platform? Use the Visual Studio Configuration Manager to make sure all referenced projects are marked to be built with the selected configuration and platform.

  • Did you use a using alias directive without fully qualifying the type name? A using alias directive does not use the using directives in the source code file to resolve types. The following example generates CS0246 because the type List<int> is not fully qualified. The using directive for System.Collections.Generic does not prevent the error.

    using System.Collections.Generic;  
    
    // The following declaration generates CS0246.  
    using myAliasName = List<int>;
    
    // To avoid the error, fully qualify List.  
    using myAliasName2 = System.Collections.Generic.List<int>;  

    If you get this error in code that was previously working, first look for missing or unresolved references in Solution Explorer. Do you need to reinstall a NuGet package? For information about how the build system searches for references, see Resolving file references in team build. If all references seem to be correct, look in your source control history to see what has changed in your .csproj file and/or your local source file.

    If you haven’t successfully accessed the reference yet, use the Object Browser to inspect the assembly that is supposed to contain this namespace and verify that the namespace is present. If you verify with Object Browser that the assembly contains the namespace, try removing the using directive for the namespace and see what else breaks. The root problem may be with some other type in another assembly.

The following example generates CS0246 because a necessary using directive is missing.

// CS0246.cs  
//using System.Diagnostics;  
  
public class MyClass  
{  
    // The following line causes CS0246. To fix the error, uncomment  
    // the using directive for the namespace for this attribute,  
    // System.Diagnostics.  
    [Conditional("A")]  
    public void Test()  
    {  
    }  
  
    public static void Main()  
    {  
    }  
}  

The following example causes CS0246 because an object of type Type was used where an actual type was expected.

// CS0246b.cs  
using System;  
  
class ExampleClass  
{  
    public bool supports(object o, Type t)  
    {  
        // The following line causes CS0246. You must use an  
        // actual type, such as ExampleClass, String, or Type.  
        if (o is t)  
        {  
            return true;  
        }  
        return false;  
    }  
}  
  
class Program  
{  
    public static void Main()  
    {  
        ExampleClass myC = new ExampleClass();  
        myC.supports(myC, myC.GetType());  
    }  
}  

    msm.ru

    Нравится ресурс?

    Помоги проекту!

    >
    error C2871: System: пространство имен с таким именем не существует

    • Подписаться на тему
    • Сообщить другу
    • Скачать/распечатать тему



    Сообщ.
    #1

    ,
    19.03.11, 16:11

      Здравствуйте форумчане!
      Почему в моей программе появляется такая ошибка?


      like-nix



      Сообщ.
      #2

      ,
      19.03.11, 16:14

        Senior Member

        ****

        Рейтинг (т): 27

        Посмотрите тут http://msdn.microsoft.com/ru-ru/library/8x5x43k7(v=VS.90).aspx

        Master

        Hsilgos



        Сообщ.
        #3

        ,
        19.03.11, 16:14

          Потому что ты скорее всего компилируешь программу написанную на C# (или скорее на C++/CLI) компилятором C++.

          Сообщение отредактировано: Hsilgos — 19.03.11, 16:17


          like-nix



          Сообщ.
          #4

          ,
          19.03.11, 16:15

            Senior Member

            ****

            Рейтинг (т): 27

            Я Вам помогу =)

            «имя»: пространство имен с таким именем не существует.
            ‘name’: a namespace with this name does not exist.
            Эта ошибка возникает при передаче идентификатора, который не является пространством имен, директиве using.

            В следующем примере показано возникновение ошибки C2871:

            ExpandedWrap disabled

              // C2871.cpp

              // compile with: /c

              using namespace d;   // C2871 d is not a namespace

              using namespace System;   // OK

            Добавлено 19.03.11, 16:16

            Цитата Hsilgos @ 19.03.11, 16:14

            C# компилятором C++.

            Интересный вариант =)

            Сообщение отредактировано: like-nix — 19.03.11, 16:17

            Guru

            Qraizer



            Сообщ.
            #5

            ,
            19.03.11, 16:20

              Дай угадаю. Создал проект C++, и писать пытаешься на ManagedC++?
              Прочти Правила, плз.


              МихаилИнженер



              Сообщ.
              #6

              ,
              19.03.11, 16:44

                Создал проект на C++. Сделал в нём форму Приветствие.h. В начале файла Приветствие.h есть строки:

                ExpandedWrap disabled

                  #pragma once

                  using namespace System;

                  using namespace System::ComponentModel;

                  using namespace System::Collections;

                  using namespace System::Windows::Forms;

                  using namespace System::Data;

                  using namespace System::Drawing;

                Компилятор начинает находить ошибки начиная со строки: using namespace System;
                Причём форму я создал автоматически с помощью мастера. Добавил на неё элементы управления и всё. Далее просто хочу вывести её на экран. Но компилятор нашёл ошибки в своём собственном коде.
                Что надо сделать чтобы пространство имён Systems сало видимым?

                Master

                Hsilgos



                Сообщ.
                #7

                ,
                19.03.11, 17:35

                  Создать другой тип проекта: VisualC++ -> CLR

                  Добавлено 19.03.11, 17:36
                  Или Other Languges -> C#, не знаю точно, что ты пытаешься сделать.


                  МихаилИнженер



                  Сообщ.
                  #8

                  ,
                  19.03.11, 17:39

                    Моя задача создать окно и научиться из этого окна вызывать другие формы на экран


                    Adil



                    Сообщ.
                    #9

                    ,
                    19.03.11, 17:47

                      Цитата МихаилИнженер @ 19.03.11, 17:39

                      Моя задача создать окно и научиться из этого окна вызывать другие формы на экран

                      Язык то какой выбрал для этого?

                      Добавлено 19.03.11, 17:48

                      Цитата МихаилИнженер @ 19.03.11, 16:44

                      Сделал в нём форму Приветствие.h. В начале файла Приветствие.h

                      Ужас какой. Что-нибудь где-нибудь когда-нибудь точно заглючит.


                      МихаилИнженер



                      Сообщ.
                      #10

                      ,
                      19.03.11, 17:54

                        А что надо делать, какой проект создавать чтобы из одной формы вызывать другую?


                        D_KEY



                        Сообщ.
                        #11

                        ,
                        19.03.11, 18:02

                          Впервую очередь, нужно решить, на каком языке писать, на С++ или С++/CLI. Соответственно выбрать проект.

                          Сообщение отредактировано: D_KEY — 19.03.11, 18:03


                          МихаилИнженер



                          Сообщ.
                          #12

                          ,
                          19.03.11, 18:12

                            Вроде как надо писать на C++. Так как ObjectARX написан на C++

                            Guru

                            ElcnU



                            Сообщ.
                            #13

                            ,
                            19.03.11, 19:11

                              как создаешь проект
                              если нужно чисто с++ + winapi то и создавай win32 poject, иначе я тебя в другой раздел направлю…

                              0 пользователей читают эту тему (0 гостей и 0 скрытых пользователей)

                              0 пользователей:

                              • Предыдущая тема
                              • .NET: Общие вопросы
                              • Следующая тема

                              Рейтинг@Mail.ru

                              [ Script execution time: 0,0376 ]   [ 16 queries used ]   [ Generated: 10.02.23, 05:04 GMT ]  

                              b_d

                              4 / 2 / 1

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

                              Сообщений: 114

                              1

                              30.04.2014, 17:05. Показов 15782. Ответов 10

                              Метки нет (Все метки)


                              почему в консоли я не могу поставить вот это

                              C++
                              1
                              
                              using namespace System;

                              рядом с этим

                              C++
                              1
                              
                              using namespace std;

                              хочу использовать

                              C++
                              1
                              
                              System::Convert::ToString();

                              в виндовс формс это уже используется а тут не получается

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



                              0



                              Каратель

                              Эксперт С++

                              6606 / 4025 / 401

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

                              Сообщений: 9,273

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

                              30.04.2014, 17:07

                              2

                              проект CLR консольный?



                              0



                              Don’t worry, be happy

                              17781 / 10545 / 2036

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

                              Сообщений: 26,517

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

                              30.04.2014, 17:07

                              3

                              Где тут? В c++/cli чтоли? Тогда причем тут раздел c++?



                              0



                              :)

                              Эксперт С++

                              4773 / 3267 / 497

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

                              Сообщений: 9,046

                              30.04.2014, 17:18

                              4

                              Цитата
                              Сообщение от Croessmah
                              Посмотреть сообщение

                              Тогда причем тут раздел c++?

                              потому что в нем не написано «only native c++» Но даже если и будет написано, всё равно такие темы будут создаваться, т.к. раздел для новичков, а им в большинстве своем неведомы различия cli-не-cli.



                              0



                              b_d

                              4 / 2 / 1

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

                              Сообщений: 114

                              30.04.2014, 17:30

                               [ТС]

                              5

                              обычный консольный проект, вот код:

                              C++
                              1
                              2
                              3
                              4
                              5
                              6
                              7
                              8
                              9
                              10
                              11
                              12
                              13
                              14
                              15
                              16
                              17
                              
                              #include <iostream>
                               
                              int score;
                              string score_s;
                               
                              using namespace std;
                              using namespace system;
                               
                              int main()
                              {
                                      score_s = "5346";
                               
                                  score = System::Convert::ToInt32(score_s);
                               
                                  system("pause");
                                  return 0;
                              }

                              Добавлено через 2 минуты
                              про using namespace system;
                              пишет необходимо использовать имя пространства времен



                              0



                              Tulosba

                              :)

                              Эксперт С++

                              4773 / 3267 / 497

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

                              Сообщений: 9,046

                              30.04.2014, 17:44

                              6

                              Цитата
                              Сообщение от b_d
                              Посмотреть сообщение

                              score = System::Convert::ToInt32(score_s);

                              b_d, откуда вы взяли это?
                              Ознакомьтесь с различиями между управляемым (managed) и неуправляемым (native) кодом C++. И решите какой вариант вам нужен. В native-варианте ваш код будет выглядеть примерно так:

                              C++
                              1
                              2
                              3
                              4
                              5
                              6
                              7
                              8
                              9
                              10
                              11
                              12
                              13
                              
                              #include <iostream>
                              #include <cstdlib>
                              #include <string>
                               
                              int main()
                              {
                                 std::string score_s = "5346";
                               
                                 int score = std::strtol(score_s.c_str(), NULL, 10); 
                               
                                 std::system("pause");
                                 return 0;
                              }



                              0



                              2644 / 2220 / 239

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

                              Сообщений: 8,064

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

                              30.04.2014, 17:56

                              7

                              Определись с проектом — он CLR или обычный (не CLR).



                              0



                              4 / 2 / 1

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

                              Сообщений: 114

                              30.04.2014, 18:37

                               [ТС]

                              8

                              обычный

                              Добавлено через 31 минуту
                              всем спасибо)
                              в .h файле — файле формы — работает, о чем я в начале и говорил, а в обычном, не clr, консольном проекте нет. в нем я просто проверял.

                              Добавлено через 1 минуту
                              проблема в общем то не решена, но ее решение уже не требуется

                              Добавлено через 22 секунды
                              вот такие пирожки)



                              0



                              Don’t worry, be happy

                              17781 / 10545 / 2036

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

                              Сообщений: 26,517

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

                              30.04.2014, 18:42

                              9

                              Цитата
                              Сообщение от b_d
                              Посмотреть сообщение

                              проблема в общем то не решена

                              clr и не clr проекты — это проекты для разных языков программирования!



                              0



                              4 / 2 / 1

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

                              Сообщений: 114

                              30.04.2014, 19:00

                               [ТС]

                              10

                              Цитата
                              Сообщение от Croessmah
                              Посмотреть сообщение

                              clr и не clr проекты — это проекты для разных языков программирования!

                              ну вот я в студии создаю пустой проект не clr — самый обычный самый пустой, самая присама консолька… пишу в ней на c++… далее создаю пустой проект clr и добавляю в него форму, в ней, то есть в .h файле, пишу… тоже на c++…



                              0



                              Don’t worry, be happy

                              17781 / 10545 / 2036

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

                              Сообщений: 26,517

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

                              30.04.2014, 19:04

                              11

                              Цитата
                              Сообщение от b_d
                              Посмотреть сообщение

                              далее создаю пустой проект clr и добавляю в него форму, в ней, то есть в .h файле, пишу… тоже на c++…

                              это уже c++/cli — другой язык



                              0



                              • Forum
                              • Beginners
                              • Error Messages about System/Namespace. N

                              Error Messages about System/Namespace. Need help.

                              I’m trying to make a program that generates a output file, but within my code, it keeps sending me these errors. I keep getting these erros

                              Error 1 error C2871: ‘System’ : a namespace with this name does not exist

                              I have 6 files and below is the code that is in them that is causing these error codes(it keeps highlighting each system line). I’ve included the fstream, manip and iostream as well as the string:

                              using namespace System;
                              using namespace System::Reflection;
                              using namespace System::Runtime::CompilerServices;
                              using namespace System::Runtime::InteropServices;
                              using namespace System::Security::Permissions;

                              using namespace std;
                              using namespace System;
                              using namespace System::IO;
                              using namespace System::Windows::Forms;
                              using namespace System::Runtime::InteropServices;

                              The namespaces you are trying to use do not exist. Why are you trying to use them? You may want to post more of your code.

                              I’ve tried to post my code but the website says its too long

                              Last edited on

                              > I’ve tried to post my code but the website says its too long

                              Try pastebin or textuploader

                              Form 1.h(not sure if I’m doing this right)

                              <script src=»//pastebin.com/embed_js/EWZzzq0N»></script>

                              Mantis.h

                              <script src=»//pastebin.com/embed_js/JY7uWRCc»></script>

                              Resource.h

                              <script src=»//pastebin.com/embed_js/t9Juf7x8″></script>

                              Stdafx.h
                              <script src=»//pastebin.com/embed_js/AV4wvXPk»></script>

                              CPP

                              Assembly Code.cpp
                              <script src=»//pastebin.com/embed_js/7RJi0AEy»></script>

                              Program3.cpp
                              <script src=»//pastebin.com/embed_js/Bdx7wdyH»></script>

                              Mantis.cpp
                              <script src=»//pastebin.com/embed_js/ew7uLEua»></script>

                              Stdafx.cpp
                              <script src=»//pastebin.com/embed_js/ZukBvKPa»></script>

                              I also have a input text file.

                              Last edited on

                              Is it Java or C# code?

                              Try adding at the top
                              #using <system.dll>
                              What version of Visual Studio do you use ?

                              its C# and we’re using Visual Studio 2012. It’s a GUI Programming with C++ class.

                              Thomas: in which file should I put the #using <system.dil> in?

                              in which file should I put the #using <system.dil> in?

                              In the file where you get the error — probably program3.cpp
                              You also might need to add #using <mscorlib.dll>

                              Wait, hold on.

                              its C# and we’re using Visual Studio 2012. It’s a GUI Programming with C++ class.

                              How are you using those two languages together? Could you post a short example program you have worked on before that demonstrates the kind of code you are writing?

                              Hey! So I finally got my program to work after starting over. Thank you guys for the help!

                              Topic archived. No new replies allowed.

                              Понравилась статья? Поделить с друзьями:
                            • Vaillant ошибка f24 устранение
                            • Using namespace system c ошибка
                            • Vaillant ошибка f22 как исправить ошибку
                            • Using namespace std error
                            • Vaillant ошибка ebusy