有人可以帮助我找到一个解决以下错误:/CLR选项
"fatal error C1190: managed targeted code requires a '/clr' option"
我的配置是..
- 的Visual Studio 2008
- 的Windows 7
这里是代码(我通过使用网络资源得到)
#using <mscorlib.dll>
using namespace System;
using namespace System::IO;
int main() {
// Create a reference to the current directory.
DirectoryInfo* di = new DirectoryInfo(Environment::CurrentDirectory);
// Create an array representing the files in the current directory.
FileInfo* fi[] = di->GetFiles();
Console::WriteLine(S"The following files exist in the current directory:");
// Print out the names of the files in the current directory.
Collections::IEnumerator* myEnum = fi->GetEnumerator();
while (myEnum->MoveNext()) {
FileInfo* fiTemp = __try_cast<FileInfo*>(myEnum->Current);
Console::WriteLine(fiTemp->Name);
}
}
您是否已经为编译器使用了/ clr选项?因为这基本上是错误消息告诉你的:http://msdn.microsoft.com/library/k8d11d4s%28VS.80%29.aspx – 2010-05-20 14:36:17