Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

need help with 'using namespace System;'

Status
Not open for further replies.

AgentOrange44

Programmer
Apr 6, 2005
13
0
0
US
I'm trying to use the Directory class to do some enumeration and the example code I found contains:

#include <stdafx.h>
#using <mscorlib.dll>
using namespace System;

my code looks like:

#define _WIN32_DCOM
#include <Wbemidl.h>
#include <iostream>
#include <string>
#include <Windows.h>
#include <IADS.h>
#include <Adshlp.h>
#include <Activeds.h>
#include <TCHAR.h>
#include <stdafx.h>

#using <mscorlib.dll>
using namespace std;
using namespace System;

The first problem I have is the compiler says that #using is an "invalid preprocessor command". If I comment that out, I get "System does not exist or is not a namespace". I get the same error if I try "System::Directory *objDir;"

Any help would be greatly appreciated.
 
Of course. no such preprocessor directive as #using.
No such namespace as System in C++ (C++ != Java). Windows API defined in a global namespace :):API_Name).
 
In the Using namespaces article System is a name for example only. Obviously, no such namespace declared in headers in your snippet.
 
It's .NET Framework sample. What VC++ version are you using?
 
I have VS 6.0 Enterprise too. No any System namespace in my VS or Win SDK headers...
 
The .NET Framework came with the .NET version of Visual Studio, right? So, if that is a .NET Framework example, it would make sense that it wouldn't work with earlier versions of Visual Studio. Version 7.0 was the first .NET version, so I doubt you could use .NET code in 6.0.

Either look for examples of plain C++ code instead of managed C++ or C#, or upgrade your compiler to version 7.0 or later.

If you are just trying to look at directories using version 6.0, use the Windows API or MFC instead of the .NET framework.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top