none
VS 2015 keeps locking my C# Win Form Application files after first run

    Question

  • Hi,

    I have the following issue and hope that someone might help me to get it sorted.

    Every time I run my C# Win Forms application for the first time after starting up VS 2015, and stopping the application again, I cannot change any files as they are all locked.

    Steps:

    1. Open/Create new windows form application.

    2. Run the application.

    3. Close the application.

    4. Try to edit anything in your project (fails with the following error: The file C:\Users***\documents\visual studio 2015\Projects\WindowsFormsApplication1\WindowsFormsApplication1\Form1.Designer.cs cannot be modified at this time.

      enter image description here

    I can see on the Form tab that it shows a lock.

    enter image description here

    At the moment the only way I can get past this is to close VS and open it again every time I want to make changes to my project.

    Hope someone can help me.

    Regards,

    Dirkie


    • Edited by dirkie1986 Monday, June 27, 2016 9:11 AM
    Thursday, June 23, 2016 10:13 AM

Answers

  • Hi dirkie,

    Have you use any version control tools before? if so, please disconnect VS with it.

    Besides, you could find another machine which VS works fine, build a new same win form project.

    Then compare  this .proj file with the locked one, see find if there is any property different or added.

    If there are some new added properties, please remove them and build again.

    Also, you could disable some AV software and some third-party application, because it might visit your project when you are running it, and it change some property so that it locked.

    Best Regards,


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.

    Click HERE to participate the survey.

    Monday, June 27, 2016 10:02 AM
    Moderator
  • Hi Dirkie,

    I think what is Lana is saying is right. As you confirmed before that you are not using source control. There may be antivirus software installed that locks your files. You can try running the exe from bin\debug folder. If you cannot run it or see a blue spinning circule so sure the antivirus is locking your exe. If so disable your anti-virus temporarily and try again.

    Please let's know if this helps.


    Thanks Mahmoud

    Monday, June 27, 2016 10:28 AM

All replies

  • Hi Dirkie,

    please make sure when you are trying to edit any of the project files like cs or designer pages that you are not running the application or debugging it, because it will lock the files from being updated or modified,

    modify what you need to then start your application after.

    hope this helps you! 


    Thanks Mahmoud

    Thursday, June 23, 2016 12:06 PM
  • Hi Mahmoud,

    Thank you for replying.

    When I open the project initially I can edit any file fine.

    But after I have ran it once, and CLOSE it again, I can not edit anything as the files are then locked.

    I can confirm that the application is closed and that no debugging is running.

    Thursday, June 23, 2016 12:12 PM
  • Hi,

    can you open the task manager and check that there is no process there with your application name?

    I suspect that the debugger ends but keeps the process up and running in the background hence preventing you from editing the files.


    Thanks Mahmoud

    Thursday, June 23, 2016 12:20 PM
  • Hi Mahmoud,

    I do actually see the following process even after closing the application:

    {applicationName}.vshost.exe *32

    Any idea why this will stay open even thought I have closed the application?

    And how can I fix it?

    Regards,

    Dirkie

    Thursday, June 23, 2016 12:41 PM
  • Hi Dirkie,

    Can you please right click your project on the Visual Studio, click Properties,

    on the Debug tab, there is a checkbox "Enable the Visual Studio hosting process", please uncheck it and try again.

    I think this may solve your problem, please let me know if still not working


    Thanks Mahmoud

    Thursday, June 23, 2016 12:46 PM
  • Hi Mahmoud,

    I have removed the option "Enable the Visual Studio hosting process", and it kills the {applicationName}.vshost.exe *32 now when I close the application, but it still locks the files, I can not edit anything after running the application once.

    Regards,

    Dirkie

    Thursday, June 23, 2016 12:58 PM
  • let's try another workaround,

    if your application files are located at document folder => visual studio projects, can you move them to another folder?

    I mean a different partition, also are you using TFS? that maybe locking your files, please check the properties of the file in the windows explorer and make sure that it's not read only.


    Thanks Mahmoud

    Thursday, June 23, 2016 1:08 PM
  • Hi Mahmoud,

    I have moved the Project from my documents folder to my D-drive, but when I open the Project and run it once it locks the files again.

    When I close VS and open the project again, I can edit, but once I run it the first time it is locked again.

    Not using TFS.

    Regards,

    Dirkie

    Friday, June 24, 2016 6:07 AM
  • I have added images to the post now...
    Monday, June 27, 2016 9:12 AM
  • Hi dirkie,

    Have you use any version control tools before? if so, please disconnect VS with it.

    Besides, you could find another machine which VS works fine, build a new same win form project.

    Then compare  this .proj file with the locked one, see find if there is any property different or added.

    If there are some new added properties, please remove them and build again.

    Also, you could disable some AV software and some third-party application, because it might visit your project when you are running it, and it change some property so that it locked.

    Best Regards,


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.

    Click HERE to participate the survey.

    Monday, June 27, 2016 10:02 AM
    Moderator
  • Hi Dirkie,

    I think what is Lana is saying is right. As you confirmed before that you are not using source control. There may be antivirus software installed that locks your files. You can try running the exe from bin\debug folder. If you cannot run it or see a blue spinning circule so sure the antivirus is locking your exe. If so disable your anti-virus temporarily and try again.

    Please let's know if this helps.


    Thanks Mahmoud

    Monday, June 27, 2016 10:28 AM
  • Any idea why this will stay open even thought I have closed the application?

    I think that is the problem to solve. Any workaround is likely to just cause the problem to happen again with a different symptom. How is the application closed? How many forms are there? Are there any tasks created, either directly or indirectly?


    Sam Hobbs
    SimpleSamples.Info

    Monday, June 27, 2016 5:24 PM