GIDForums  

Go Back   GIDForums > Computer Programming Forums > .NET Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 07-Sep-2008, 03:14
Napcrisis Napcrisis is offline
New Member
 
Join Date: Sep 2008
Posts: 8
Napcrisis is an unknown quantity at this point

Error C2871: 'System' : a namespace with this name does not exist


hi .. im new to using visual c++ and kinda got stuck.. hope any1 can help out thx.
when i add in the sample code to try out ...i keep getting a
when running in visual c++
"error C2871: 'System' : a namespace with this name does not exist"
however when compiling in command prompt they do not complain that the error above.. why and how to solve?
  #2  
Old 07-Sep-2008, 07:41
davekw7x davekw7x is offline
Outstanding Member
 
Join Date: Feb 2004
Location: Left Coast, USA
Posts: 5,311
davekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to beholddavekw7x is a splendid one to behold

Re: Hi i got a problem when using visual c++


Quote:
Originally Posted by Napcrisis
...i keep getting a...
"error C2871: 'System' : a namespace with this name does not exist"...
How about posting the code?

Regards,

Dave
  #3  
Old 07-Sep-2008, 13:27
dlp dlp is offline
Member
 
Join Date: May 2006
Posts: 157
dlp has a spectacular aura about

Re: Hi i got a problem when using visual c++


And command line arguments.
  #4  
Old 08-Sep-2008, 00:03
Napcrisis Napcrisis is offline
New Member
 
Join Date: Sep 2008
Posts: 8
Napcrisis is an unknown quantity at this point

Re: Hi i got a problem when using visual c++


command line argument meaning this?
g++ -c main.cpp -o main.o
  #5  
Old 08-Sep-2008, 00:05
Napcrisis Napcrisis is offline
New Member
 
Join Date: Sep 2008
Posts: 8
Napcrisis is an unknown quantity at this point

Re: Hi i got a problem when using visual c++


Below are the codes im trying out
--------------------------------
CPP / C++ / C Code:
#include "stdafx.h"
using namespace System.IO;

bool WipeFile (String * inFilePath, int nWipes )
{
    bool status = false;
    FileStream * sw;
    Byte Patterns[];
    __int64 fileLength=0;
    int patIndex =0;

    if (nWipes<1) nWipes =1;
    else if (nWipes>200) nWipes=200;

    try {
        // Open the file with exclusive access

        sw = new FileStream (inFilePath, FileMode::Open ,
                 FileAccess::Write, FileShare::None);

        Patterns = new Byte[nWipes] ;
        // Create a pattern index


        for (patIndex = 0; patIndex < 
            Patterns->Count ; patIndex++) 
            Patterns[patIndex] = patIndex;

        fileLength = sw->Length ;
        for (patIndex=0; patIndex < 
            Patterns->Count ; patIndex++) 
        {
            sw->Seek (0,SeekOrigin::Begin );
            for (int i =0; i <= fileLength ;i++)
                sw->Write (Patterns,patIndex,1);
          }
        sw->Flush ();
        sw->Close ();

        // Safe to remove the file now

        File::Delete (inFilePath);
        status = true;
        }
        catch (Exception * e) 
        {
            Console::Writeline (e->ToString());
        }
    return status;
}
Last edited by LuciWiz : 08-Sep-2008 at 02:46. Reason: Please insert your C++ code between [cpp] & [/cpp] tags
  #6  
Old 08-Sep-2008, 02:50
LuciWiz's Avatar
LuciWiz LuciWiz is offline
Moderator
 
Join Date: Jul 2004
Location: Cluj-Napoca (Romania)
Posts: 1,031
LuciWiz is a jewel in the roughLuciWiz is a jewel in the roughLuciWiz is a jewel in the roughLuciWiz is a jewel in the rough

Re: Hi i got a problem when using visual c++


It appears you are trying to compile C++ Managed code with gcc. I am not all up to speed with the latest gcc features, but I doubt it supports the .NET Framework.

Please clarify what your target OS and compiler are, perhaps we can suggest an alternative.

Best regards,
Lucian
__________________
Please read these Guidelines before posting on the forum

"A person who never made a mistake never tried anything new."
Einstein
  #7  
Old 09-Sep-2008, 08:18
Napcrisis Napcrisis is offline
New Member
 
Join Date: Sep 2008
Posts: 8
Napcrisis is an unknown quantity at this point

Re: Hi i got a problem when using visual c++


thanks lucian
target OS - windows
Compiler - visual c++
well the main problem is about the visual c++ not the gcc compiler since im not using gcc for the actual work. The problem seems to be incorrect settings.. i did some searches on C2871 before and the fix was to change to /clr which i also tried but kept getting incompartibility issue. is there any default settings(referencing library) that must be done before?

o btw do anybody know how can i generate a set of keys for AES (128,192,256) using a passphrase?
  #8  
Old 09-Sep-2008, 08:59
LuciWiz's Avatar
LuciWiz LuciWiz is offline
Moderator
 
Join Date: Jul 2004
Location: Cluj-Napoca (Romania)
Posts: 1,031
LuciWiz is a jewel in the roughLuciWiz is a jewel in the roughLuciWiz is a jewel in the roughLuciWiz is a jewel in the rough

Re: Hi i got a problem when using visual c++


Quote:
Originally Posted by Napcrisis
The problem seems to be incorrect settings.. i did some searches on C2871 before and the fix was to change to /clr which i also tried but kept getting incompartibility issue. is there any default settings(referencing library) that must be done before?


When you created the project, did you use a template from the "CLR" category? If not, I suggest you recreate it, to make sure there are no incompatible settings carried from the wrong project type. A good choice might be the "CLR Console Application" type.

Second, change your using statement:

CPP / C++ / C Code:
// using namespace System.IO;   Wrong
using namespace System::IO;  // Correct


Best regards,
Lucian
__________________
Please read these Guidelines before posting on the forum

"A person who never made a mistake never tried anything new."
Einstein
  #9  
Old 09-Sep-2008, 09:00
LuciWiz's Avatar
LuciWiz LuciWiz is offline
Moderator
 
Join Date: Jul 2004
Location: Cluj-Napoca (Romania)
Posts: 1,031
LuciWiz is a jewel in the roughLuciWiz is a jewel in the roughLuciWiz is a jewel in the roughLuciWiz is a jewel in the rough

Re: Hi i got a problem when using visual c++



Once the OP responds and acknowledges this message, I will move this thread to the .NET Forum.
__________________
Please read these Guidelines before posting on the forum

"A person who never made a mistake never tried anything new."
Einstein
  #10  
Old 09-Sep-2008, 20:06
Napcrisis Napcrisis is offline
New Member
 
Join Date: Sep 2008
Posts: 8
Napcrisis is an unknown quantity at this point

Re: Error C2871: 'System' : a namespace with this name does not exist


o lol thanks lucian that solves one part
 
 

Recent GIDBlogVista ?Widgets? on Windows XP by LocalTech

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Build error with darkGDK header files ? genesaika MS Visual C++ / MFC Forum 4 24-Jul-2008 19:07
Major newbie problem cynack MS Visual C++ / MFC Forum 1 08-Apr-2007 11:25
problem with visual studio project veronica_yick MS Visual C++ / MFC Forum 0 26-Feb-2007 00:22
Problem using std::stringbuf under Visual C++ QED C++ Forum 3 23-Sep-2005 14:27
Visual C++ Tool Problem wolfban MS Visual C++ / MFC Forum 0 23-Jul-2005 17:24

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 03:08.


vBulletin, Copyright © 2000 - 2010, Jelsoft Enterprises Ltd.