none
How do I find the code holdng a file? RRS feed

  • Question

  • I have a set TFS build activities that I use for my automated build. For some reason, somewhere in my code (I assume) I’m holding a lock on a file. Because of this lock, my second build fails.

    I’ve used handle (sysinternals), to verify witch process holds the file (witch of course is TFS), but I need to know which class.

    So the question is, -based on the trace below, what would I need to do next?

    Thank you!

    474: Section \BaseNamedObjects\net.pipe:EbmV0LnBpcGU6Ly8rL1NFUlZJQ0VIT1NULzEv
    494: File (R-D) C:\Windows\Microsoft.NET\assembly\GAC_MSIL\Microsoft.Build.Framework\v4.0_4.0.0.0__b03f5f7f11d50a3a\Microsoft.Build.Framework.dll
    4C8: File (R-D) C:\Windows\Microsoft.NET\assembly\GAC_MSIL\Microsoft.CSharp\v4.0_4.0.0.0__b03f5f7f11d50a3a\Microsoft.CSharp.dll
    538: File (R-D) C:\Windows\Microsoft.NET\assembly\GAC_MSIL\System.ServiceModel\v4.0_4.0.0.0__b77a5c561934e089\System.ServiceModel.dll
    540: File (R-D) C:\Windows\Microsoft.NET\assembly\GAC_MSIL\System\v4.0_4.0.0.0__b77a5c561934e089\System.dll
    548: File (R-D) C:\Windows\Microsoft.NET\assembly\GAC_64\System.Transactions\v4.0_4.0.0.0__b77a5c561934e089\System.Transactions.dll
    564: File (R-D) C:\Windows\assembly\GAC_MSIL\Microsoft.TeamFoundation.Client\10.0.0.0__b03f5f7f11d50a3a\Microsoft.TeamFoundation.Client.dll
    56C: File (R-D) C:\Windows\assembly\GAC_MSIL\Microsoft.TeamFoundation.Build.Client\10.0.0.0__b03f5f7f11d50a3a\Microsoft.TeamFoundation.Build.Client.dll
    574: File (R-D) C:\Windows\assembly\GAC_MSIL\Microsoft.TeamFoundation.Common\10.0.0.0__b03f5f7f11d50a3a\Microsoft.TeamFoundation.Common.dll
    57C: File (R-D) C:\Windows\assembly\GAC_MSIL\Microsoft.TeamFoundation.VersionControl.Client\10.0.0.0__b03f5f7f11d50a3a\Microsoft.TeamFoundation.VersionControl.Client.dll
    584: File (R-D) C:\Windows\Microsoft.NET\assembly\GAC_MSIL\System.ServiceProcess\v4.0_4.0.0.0__b03f5f7f11d50a3a\System.ServiceProcess.dll
    58C: File (R-D) C:\Windows\assembly\GAC_MSIL\Microsoft.TeamFoundation.Build.Common\10.0.0.0__b03f5f7f11d50a3a\Microsoft.TeamFoundation.Build.Common.dll
    59C: File (R-D) C:\Windows\Microsoft.NET\assembly\GAC_MSIL\System.Core\v4.0_4.0.0.0__b77a5c561934e089\System.Core.dll
    5B8: File (R-D) C:\Builds\2\AIP\INT002_InfoService\Binaries\INT002.HelperComponents.dll


    If this answers your question, please use the "Answer" button to say so... Mikael - http://blogical.se/blogs/mikael
    Monday, September 26, 2011 8:26 AM

Answers

  • Well, I never got to understand how to find the actual class, but as I found the source to the problem, I thought I'd share it:

    The line of code that locked the files was this:

    Assembly.LoadFile(path);

    When I changed it to this, it no longer locks the file:

    Assembly.Load(System.IO.File.ReadAllBytes(path));

     

    HTH

     


    If this answers your question, please use the "Answer" button to say so... Mikael - http://blogical.se/blogs/mikael
    Monday, September 26, 2011 11:26 AM

All replies

  • Well, I never got to understand how to find the actual class, but as I found the source to the problem, I thought I'd share it:

    The line of code that locked the files was this:

    Assembly.LoadFile(path);

    When I changed it to this, it no longer locks the file:

    Assembly.Load(System.IO.File.ReadAllBytes(path));

     

    HTH

     


    If this answers your question, please use the "Answer" button to say so... Mikael - http://blogical.se/blogs/mikael
    Monday, September 26, 2011 11:26 AM
  • Thanks for sharing Mikael.
    Min Zhu [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Tuesday, September 27, 2011 2:53 AM
    Moderator