none
VS2012 Build - Copy files RRS feed

  • Question

  • For years I have performed the following steps when testing .DLL's

    1. Open the .DLL project being tested (e.g. dbCommonLRX.dll)
    2. Create a forms app with a button. and a reference to the .DLL
    3. --
    4. In the button click add enough code to test the .DLL
    5. Run the app. Examine results. Close the app
    6. --
    7. for arguments sake the .DLL had to be fixed
    8. switch to the .DLL project, make changes and rebuild
    9. Continue steps 5 - 8 until results are correct


    Today I get errors(see below) at step 8 when building the .DLL. If I close the app I don't get errors.

    Errors fron .DLL build:

    Could not copy "obj\Release\dbCommonLRX.dll" to "bin\Release\dbCommonLRX.dll". Exceeded retry count of 10. Failed. dbCommonLRX

    Unable to copy file "obj\Release\dbCommonLRX.dll" to "bin\Release\dbCommonLRX.dll". The process cannot access the file 'bin\Release\dbCommonLRX.dll' because it is being used by another process. dbCommonLRX

    We were off Tuesday. On Monday the above worked.

    I have restarted my PC to no avail. I am just at a loss why this started happening.

    Search Documentation

    SerialPort Info

    Multics - An OS ahead of its time.

     "Those who use Application.DoEvents have no idea what it does

        and those who know what it does never use it."    former MSDN User JohnWein

    Wednesday, February 13, 2019 8:18 PM

Answers

  • Can you put some pre-build events in your project, I know you shouldn't have to, but it may just help with this. The below, just copy and paste into your project build events.

    if exist "$(TargetPath).locked" del "$(TargetPath).locked"
    if exist "$(TargetPath)" if not exist "$(TargetPath).locked" move "$(TargetPath)" "$(TargetPath).locked"


    Regards,

    Trevor White

    Note: Posts are provided “AS IS” without warranty of any kind, either expressed or implied, including but not limited to the implied warranties of merchantability and/or fitness for a particular purpose.

    • Marked as answer by dbasnett Friday, February 15, 2019 2:38 PM
    Thursday, February 14, 2019 10:07 PM

All replies

  • Greetings,

    Try deleting the OBJ and BIN folders (from both class and forms project) from Windows Explorer then attempt to rebuild.


    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
    VB Forums - moderator
    profile for Karen Payne on Stack Exchange, a network of free, community-driven Q&A sites

    Wednesday, February 13, 2019 8:35 PM
    Moderator
  • Greetings,

    Try deleting the OBJ and BIN folders (from both class and forms project) from Windows Explorer then attempt to rebuild.


    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
    VB Forums - moderator
    profile for Karen Payne on Stack Exchange, a network of free, community-driven Q&A sites


    Didn't mention it in my original post but I did do that also.  This is weird, especially because it has always worked and it is complaining about copying to itself.

    Search Documentation

    SerialPort Info

    Multics - An OS ahead of its time.

     "Those who use Application.DoEvents have no idea what it does

        and those who know what it does never use it."    former MSDN User JohnWein

    Wednesday, February 13, 2019 9:45 PM
  • Here is another idea, a bit out there. Close all editor windows that are either source code or project property windows and delete OBJ and BIN followed by a build.

    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
    VB Forums - moderator
    profile for Karen Payne on Stack Exchange, a network of free, community-driven Q&A sites

    Thursday, February 14, 2019 12:14 AM
    Moderator
  • And one last off the wall idea. Under properties, debug, deselect "Enable the Visual Studio hosting process".

    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
    VB Forums - moderator
    profile for Karen Payne on Stack Exchange, a network of free, community-driven Q&A sites

    Thursday, February 14, 2019 12:24 AM
    Moderator
  • Karen - tried suggestions in both posts.  No JOY!!!  This is so frustrating.

    Search Documentation

    SerialPort Info

    Multics - An OS ahead of its time.

     "Those who use Application.DoEvents have no idea what it does

        and those who know what it does never use it."    former MSDN User JohnWein

    Thursday, February 14, 2019 4:09 PM
  • Karen - tried suggestions in both posts.  No JOY!!!  This is so frustrating.

    Search Documentation

    SerialPort Info

    Multics - An OS ahead of its time.

     "Those who use Application.DoEvents have no idea what it does

        and those who know what it does never use it."    former MSDN User JohnWein


    I also tried Repairing Visual Studio.

    Search Documentation

    SerialPort Info

    Multics - An OS ahead of its time.

     "Those who use Application.DoEvents have no idea what it does

        and those who know what it does never use it."    former MSDN User JohnWein

    Thursday, February 14, 2019 4:41 PM
  • Try creating a new class project, add in the files (classes and code modules) from the broken project and try a build solely on the new project.

    I'm sure you have seen the same and similar issues across the web where all pretty much were solved with what you have tried so far so this is out there.


    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
    VB Forums - moderator
    profile for Karen Payne on Stack Exchange, a network of free, community-driven Q&A sites

    Thursday, February 14, 2019 5:09 PM
    Moderator
  • Try creating a new class project, add in the files (classes and code modules) from the broken project and try a build solely on the new project.

    I'm sure you have seen the same and similar issues across the web where all pretty much were solved with what you have tried so far so this is out there.


    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
    VB Forums - moderator
    profile for Karen Payne on Stack Exchange, a network of free, community-driven Q&A sites

    And that fails also. 

    In the error it says that it is in:

    C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets at line 3390.

    There you find this

        <!-- Copy the build product (.dll or .exe). -->
        <Copy
            SourceFiles="@(IntermediateAssembly)"
            DestinationFolder="$(OutDir)"
            SkipUnchangedFiles="$(SkipCopyUnchangedFiles)"
            OverwriteReadOnlyFiles="$(OverwriteReadOnlyFiles)"
            Retries="$(CopyRetryCount)"
            RetryDelayMilliseconds="$(CopyRetryDelayMilliseconds)"
            UseHardlinksIfPossible="$(CreateHardLinksForCopyFilesToOutputDirectoryIfPossible)"
            Condition="'$(CopyBuildOutputToOutputDirectory)' == 'true' and '$(SkipCopyBuildProduct)' != 'true'"
                >
    
          <Output TaskParameter="DestinationFiles" ItemName="MainAssembly"/>
          <Output TaskParameter="DestinationFiles" ItemName="FileWrites"/>
    
        </Copy>
    


    So I looked for the definition of

    $(OverwriteReadOnlyFiles)

    And found it

        <OverwriteReadOnlyFiles Condition="'$(OverwriteReadOnlyFiles)' == ''">false</OverwriteReadOnlyFiles>
    

    The only problem is that I can't save the file after changing it to true.  Don't know that it would fix it.

    Also I don't understand why this happens.  I am not alone and from what I can find no one else does either.

    If I was sure that I could install VS2017 and not break everything I would.  I am trying find the VS2012 install so I can uninstall and reinstall it.

    Of course this happens when there are a lot of things to do, and diagnosing this wasn't on the list.

    F-Bomb


    Search Documentation

    SerialPort Info

    Multics - An OS ahead of its time.

     "Those who use Application.DoEvents have no idea what it does

        and those who know what it does never use it."    former MSDN User JohnWein

    Thursday, February 14, 2019 5:47 PM
  • And it gets worse... I have a web page (.ASPX) app that I can only run once in visual studio.  If I make changes I have to close the project, delete the obj / bin folders and then try again.  Same error copying obj to bin...

    Search Documentation

    SerialPort Info

    Multics - An OS ahead of its time.

     "Those who use Application.DoEvents have no idea what it does

        and those who know what it does never use it."    former MSDN User JohnWein

    Thursday, February 14, 2019 9:20 PM
  • Hello dbasnett,

    I have had this happen to myself before, found out it's actually still running in the background. Have you tried going to task manager and looking for it and then closing it and then rebuilt it?


    Regards,

    Trevor White

    Note: Posts are provided “AS IS” without warranty of any kind, either expressed or implied, including but not limited to the implied warranties of merchantability and/or fitness for a particular purpose.


    • Edited by Trevor_White Thursday, February 14, 2019 9:53 PM
    Thursday, February 14, 2019 9:52 PM
  • Hello dbasnett,

    I have had this happen to myself before, found out it's actually still running in the background. Have you tried going to task manager and looking for it and then closing it and then rebuilt it?


    Regards,

    Trevor White

    Note: Posts are provided “AS IS” without warranty of any kind, either expressed or implied, including but not limited to the implied warranties of merchantability and/or fitness for a particular purpose.



    Yep.

    Search Documentation

    SerialPort Info

    Multics - An OS ahead of its time.

     "Those who use Application.DoEvents have no idea what it does

        and those who know what it does never use it."    former MSDN User JohnWein

    Thursday, February 14, 2019 9:59 PM
  • Can you put some pre-build events in your project, I know you shouldn't have to, but it may just help with this. The below, just copy and paste into your project build events.

    if exist "$(TargetPath).locked" del "$(TargetPath).locked"
    if exist "$(TargetPath)" if not exist "$(TargetPath).locked" move "$(TargetPath)" "$(TargetPath).locked"


    Regards,

    Trevor White

    Note: Posts are provided “AS IS” without warranty of any kind, either expressed or implied, including but not limited to the implied warranties of merchantability and/or fitness for a particular purpose.

    • Marked as answer by dbasnett Friday, February 15, 2019 2:38 PM
    Thursday, February 14, 2019 10:07 PM