打开资源管理器窗口后,C#exe文件被锁定,我收到“错误CS0016:无法写入输出文件”

时间:2016-10-16 02:17:11

标签: c# csc

如果我在目录start .中打开一个资源管理器窗口,那么一旦我这样做,我就无法编译它,甚至在我关闭资源管理器窗口后,我无法编译它或删除它exe文件有一段时间。

C:\blah\ff>notepad.exe asdf.csc

C:\blah\ff>type asdf.csc
class a {  public static void Main(string[] args){} }
C:\blah\ff>
C:\blah\ff>csc asdf.csc
Microsoft (R) Visual C# Compiler version 4.6.1055.0
for C# 5
Copyright (C) Microsoft Corporation. All rights reserved.

This compiler is provided as part of the Microsoft (R) .NET Framework, but only supports language versions up to C# 5, which is no longer the latest v
ersion. For compilers that support newer versions of the C# programming language, see http://go.microsoft.com/fwlink/?LinkID=533240


C:\blah\ff>csc asdf.csc
Microsoft (R) Visual C# Compiler version 4.6.1055.0
for C# 5
Copyright (C) Microsoft Corporation. All rights reserved.

This compiler is provided as part of the Microsoft (R) .NET Framework, but only supports language versions up to C# 5, which is no longer the latest v
ersion. For compilers that support newer versions of the C# programming language, see http://go.microsoft.com/fwlink/?LinkID=533240


C:\blah\ff>csc asdf.csc
Microsoft (R) Visual C# Compiler version 4.6.1055.0
for C# 5
Copyright (C) Microsoft Corporation. All rights reserved.

This compiler is provided as part of the Microsoft (R) .NET Framework, but only supports language versions up to C# 5, which is no longer the latest v
ersion. For compilers that support newer versions of the C# programming language, see http://go.microsoft.com/fwlink/?LinkID=533240

^^没有问题在那里编译,现在看看当我做start .

时会发生什么
C:\blah\ff>start .

C:\blah\ff>csc asdf.csc
Microsoft (R) Visual C# Compiler version 4.6.1055.0
for C# 5
Copyright (C) Microsoft Corporation. All rights reserved.

This compiler is provided as part of the Microsoft (R) .NET Framework, but only supports language versions up to C# 5, which is no longer the latest v
ersion. For compilers that support newer versions of the C# programming language, see http://go.microsoft.com/fwlink/?LinkID=533240

error CS0016: Could not write to output file 'c:\blah\ff\asdf.exe' -- 'The process cannot access the file because it is being used by another process.
        '

C:\blah\ff>csc asdf.csc
Microsoft (R) Visual C# Compiler version 4.6.1055.0
for C# 5
Copyright (C) Microsoft Corporation. All rights reserved.

This compiler is provided as part of the Microsoft (R) .NET Framework, but only supports language versions up to C# 5, which is no longer the latest v
ersion. For compilers that support newer versions of the C# programming language, see http://go.microsoft.com/fwlink/?LinkID=533240

error CS0016: Could not write to output file 'c:\blah\ff\asdf.exe' -- 'The process cannot access the file because it is being used by another process.
        '

C:\blah\ff>

过了一段时间我可以编译,我可以删除exe文件。

现在我将再次演示,这次显示删除exe文件的问题

看我能编译('我等了一会儿,我觉得“已经解决了”)

C:\blah\ff>csc asdf.csc
Microsoft (R) Visual C# Compiler version 4.6.1055.0
for C# 5
Copyright (C) Microsoft Corporation. All rights reserved.

This compiler is provided as part of the Microsoft (R) .NET Framework, but only supports language versions up to C# 5, which is no longer the latest v
ersion. For compilers that support newer versions of the C# programming language, see http://go.microsoft.com/fwlink/?LinkID=533240

现在我将触发问题

C:\blah\ff>start .

C:\blah\ff>csc asdf.csc
Microsoft (R) Visual C# Compiler version 4.6.1055.0
for C# 5
Copyright (C) Microsoft Corporation. All rights reserved.

This compiler is provided as part of the Microsoft (R) .NET Framework, but only supports language versions up to C# 5, which is no longer the latest v
ersion. For compilers that support newer versions of the C# programming language, see http://go.microsoft.com/fwlink/?LinkID=533240

error CS0016: Could not write to output file 'c:\blah\ff\asdf.exe' -- 'The process cannot access the file because it is being used by another process.
        '

^^,因为你看到它没有编译

C:\blah\ff>del asdf.exe

C:\blah\ff>dir
 Volume in drive C has no label.
 Volume Serial Number is B411-D580

 Directory of C:\blah\ff

16/10/2016  03:13 AM    <DIR>          .
16/10/2016  03:13 AM    <DIR>          ..
16/10/2016  03:10 AM                53 asdf.csc
16/10/2016  03:13 AM             3,584 asdf.exe
               2 File(s)          3,637 bytes
               2 Dir(s)   2,886,389,760 bytes free

^^看看exe文件还在那里 让我们再试一次删除它

C:\blah\ff>del asdf.exe
C:\blah\ff\asdf.exe
Access is denied.

C:\blah\ff>

所以当我等着它让我删除它或让我编译一个同名的exe时,我使用csc /out:asdf_.exe asdf.csc这是好的但不理想。

0 个答案:

没有答案