none
Compiler Problem RRS feed

  • Question

  • Hello

    I am trying to use compiler to compile a very simple C# program that prints 'hello world', I tried this code in Visual Studio and it worked , there is no bug. However, after I saved a Notepad file with the extension ".cs" and tried to run it through Developer Command Prompt using compiler, it gave me this error: error CS2012: Cannot open "...." for writing--visit to this path "..." was denied. Can some one help me? Thank you very very much!

    Thursday, December 22, 2016 12:09 AM

All replies

  • Most likely permission problem. Are you trying to compile the EXE file to a location that you don't have write access to?

    For example, the default location when you launch your developer command prompt is under Program Files folder that requires elevation to write. Try specify output filename to write the EXE to a folder that you can write to instead.

    The other possibility is, when your EXE file is running, you cannot write to the same file. On that case just close the application process and recompile than it should be okay.

    Thursday, December 22, 2016 2:54 AM
    Answerer
  • Hi,

    Did you check the xx.csproj file? the csproj file will contain path of cs file

    <ItemGroup>
        <Compile Include="Class1.cs" />
        <Compile Include="Program.cs" />
        <Compile Include="Properties\AssemblyInfo.cs" />
      </ItemGroup>
      <ItemGroup>

    I think you need to add the above command in xx.csproj file.

    Best Regards,

    Hart


    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, January 12, 2017 6:29 AM
  • Humm... in his case the compiler is trying to open the path for write access and got access denied. I don't think it's related to missing project items.
    Friday, January 13, 2017 2:33 AM
    Answerer