Visual Studio的疯狂了:“目录名称无效”试图编译时错误 [英] Visual Studio gone bonkers: 'The directory name is invalid' error when trying to compile

查看:1141
本文介绍了Visual Studio的疯狂了:“目录名称无效”试图编译时错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于一些非常奇怪的原因,我的Visual Studio 2008中,尝试编译C#项目时,试图将可执行输出写入到具有相同的名称作为可执行文件的目录,至少它似乎这就是错误消息暗示。在任何我的项目运行编译后,CSC.EXE报告以下编译器错误:

For some very odd reason, my Visual Studio 2008, when trying to compile a C# project, tries to write the output of the executable to a directory with the same name as an executable, at least it seems that that's what the error message implies. After running Compile on any of my projects, CSC.EXE reports the following compiler error:

无法写入输出文件
'D:\Projects\Examples\StringBuilderVsString\obj\Release\StringBuilderVsString.exe'
- 目录名称是无效的。

当我往里 obj\Release obj\Debug 所有中间资源,如StringBuilderVsString.pdb是否正确写入该目录中。有目录中没有空格。运行从命令提示符CSC.EXE在错误发生时也。

When I look inside obj\Release or obj\Debug all intermediate resources, like StringBuilderVsString.pdb are correctly written in that directory. There are no spaces in the directory. The error happens also when running csc.exe from the command prompt.

在运行进程监视器,我只看到由CSC.EXE访问的文件成功,我不看到任何查询或写入到做不存在的位置。

When running Process Monitor, I only see SUCCESS for files accessed by csc.exe and I don't see any querying or writing to locations that do no exist.

在处理这个欢迎任何想法。

Any ideas on tackling this are welcome.

推荐答案

解决了!感谢您的输入,同时我发现了一个解决方案。其原因是罕见的,但它可能发生在别人,所以我决定在这里回答我的问题:

Solved! Thanks for the input, I meanwhile found a solution. The cause is rare, but it may happen to others, so I decided to answer my own question here:

这是不正确或无法访问%TEMP%位置,或无法访问%USERPROFILE%路径。

An incorrect or inaccessible %TEMP% location, or an inaccessible %USERPROFILE% path.

我搬到这些路径,以更快的SSD驱动器,以加快编制。该驱动器崩溃和OS没有发现它了(作为报道的上ServerFault这里),因此,移动后的位置(互联网缓存,我的文档和温度)已经成为不可访问。

I had moved these paths to a faster SSD drive to speed up compiling. The drive crashed and the OS did not find it anymore (as reported on ServerFault here) and consequently, the moved locations (internet caches, my documents and temp) had become inaccessible.

由Visual Studio中提到的错误是一种误导:它无关的文件的名称(而我仍然不知道为什么它被查询的可执行文件作为目录),误差约在%TEMP%位置是坏。

The error mentioned by Visual Studio is misleading: it has nothing to do with the name of the file (while I'm still wondering why it was querying the executable as a directory), the error was about the %TEMP% location being bad.

修复%USERPROFILE%%TEMP%环境变量,(在你忘记的情况下,它在这里:系统>高级>环境变量的)。

Fix the %USERPROFILE% or %TEMP% environment variables, (in case you forgot, it's here: System > Advanced > Environment Variables).

注:典型的默认设置TEMP是使用USERPROFILE环境变量作为默认的%USERPROFILE%\AppData\Local\\ \\Temp 。这工作,但前提是在注册表中,在 HKCU\Environment\TEMP 关键是类型 REG_EXPAND_SZ 而不是 REG_SZ

Note: The typical and default TEMP setting is to use the USERPROFILE environment variable as in the default %USERPROFILE%\AppData\Local\Temp. This works, but only if in the registry, the key under HKCU\Environment\TEMP is of the type REG_EXPAND_SZ and not REG_SZ.

这篇关于Visual Studio的疯狂了:“目录名称无效”试图编译时错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆