none
ClickOnce error -- Lock timeout exception

    Question

  • We have a .NET 2.0 application deployed using ClickOnce -- widespread use, so the deployment itself appears fine.  We've had a user report an instalation error with the following details.   We're already having the user take the usual steps to remove a possibly corrupted ClickOnce cache -- any other ideas?

    PLATFORM VERSION INFO
        Windows             : 5.1.2600.131072 (Win32NT)
        Common Language Runtime     : 2.0.50727.42
        System.Deployment.dll         : 2.0.50727.42 (RTM.050727-4200)
        mscorwks.dll             : 2.0.50727.42 (RTM.050727-4200)
        dfdll.dll             : 2.0.50727.42 (RTM.050727-4200)
        dfshim.dll             : 2.0.50727.42 (RTM.050727-4200)

    ERROR DETAILS
        Following errors were detected during this operation.
        * [11/17/2010 7:45:25 AM] System.Deployment.Application.DeploymentException (LockTimeout)
            - Lock timeout exception.
            - Source: System.Deployment
            - Stack trace:
                at System.Deployment.Application.LockedFile.AcquireLock(String path, TimeSpan timeout, Boolean writer)
                at System.Deployment.Application.SubscriptionStore.AcquireLock(DefinitionIdentity asmId, Boolean writer)
                at System.Deployment.Application.SubscriptionStore.RefreshStorePointer()
                at System.Deployment.Application.ApplicationActivator.PerformDeploymentActivation(Uri activationUri, Boolean isShortcut)
                at System.Deployment.Application.ApplicationActivator.ActivateDeploymentWorker(Object state)

    Wednesday, November 17, 2010 5:27 PM

All replies

  • Hi Richard,

     

    Here is the source code of LockedFile.AcquireLock from reflector.

    public static IDisposable AcquireLock(string path, TimeSpan timeout, bool writer)

            {

                FileAccess write;

                NativeMethods.GenericAccess access2;

                NativeMethods.ShareMode mode;

                LockedFileHandle handle = LockHeldByThread(path, writer);

                if (handle != null)

                {

                    return handle;

                }

                DateTime time = DateTime.UtcNow + timeout;

                if (writer)

                {

                    write = FileAccess.Write;

                    access2 = NativeMethods.GenericAccess.GENERIC_WRITE;

                    mode = NativeMethods.ShareMode.FILE_SHARE_NONE;

                }

                else

                {

                    write = FileAccess.Read;

                    access2 = -2147483648;

                    mode = PlatformSpecific.OnWin9x ? NativeMethods.ShareMode.FILE_SHARE_READ : (NativeMethods.ShareMode.FILE_SHARE_DELETE | NativeMethods.ShareMode.FILE_SHARE_READ);

                }

                while (true)

                {

                    SafeFileHandle handle2 = NativeMethods.CreateFile(path, (uint)access2, (uint)mode, IntPtr.Zero, 4, 0x4000000, IntPtr.Zero);

                    int num = Marshal.GetLastWin32Error();

                    if (!handle2.IsInvalid)

                    {

                        return new LockedFileHandle(handle2, path, write);

                    }

                    if ((num != 0x20) && (num != 5))

                    {

                        Marshal.ThrowExceptionForHR(Marshal.GetHRForLastWin32Error());

                    }

                    if (DateTime.UtcNow > time)

                    {

                        throw new DeploymentException(ExceptionTypes.LockTimeout, Resources.GetString("Ex_LockTimeoutException"));

                    }

                    Thread.Sleep(1);

                }

            }

    That seems the code process running too long time. The method “NativeMethods.CreateFile” doesn’t return valid handle. It would be better if you can know the path parameter when calling CreateFile.

     

    Sincerely,

    Kira Qian

    MSDN Subscriber Support in Forum

    If you have any feedback on our support, please contact msdnmg@microsoft.com
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework!
    Thursday, November 18, 2010 3:27 AM
  • I am writing to check the status of the issue on your side. Could you please let me know if the suggestion works for you? If you have any questions or concerns, please feel free to let me know. I will be more than happy to be of assistance.


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework!
    Monday, November 29, 2010 9:20 AM
  • Is there any resolution to this. I cleared the click once cache and it still got the same error.

    PLATFORM VERSION INFO 

                    Windows                                             : 5.1.2600.196608 (Win32NT)

                    Common Language Runtime       : 4.0.30319.1

                    System.Deployment.dll                                : 4.0.30319.1 (RTMRel.030319-0100)

                    clr.dll                                     : 4.0.30319.1 (RTMRel.030319-0100)

                    dfdll.dll                                                 : 4.0.30319.1 (RTMRel.030319-0100)

                    dfshim.dll                                            : 4.0.31106.0 (Main.031106-0000)

     

    SOURCES

                    Deployment url                                                : http://xxxsetup/xxx.application

     

    ERROR SUMMARY

                    Below is a summary of the errors, details of these errors are listed later in the log.

                    * Activation of http://xxxsetup/xxx.application resulted in exception. Following failure messages were detected:

                                    + Lock timeout exception.

     

    COMPONENT STORE TRANSACTION FAILURE SUMMARY

                    No transaction error was detected.

     

    WARNINGS

                    There were no warnings during this operation.

     

    OPERATION PROGRESS STATUS

                    * [2/17/2011 9:56:08 AM] : Activation of http://xxxsetup/xxx.application has started.

     

    ERROR DETAILS

                    Following errors were detected during this operation.

                    * [2/17/2011 9:58:08 AM] System.Deployment.Application.DeploymentException (LockTimeout)

                                    - Lock timeout exception.

                                    - Source: System.Deployment

                                    - Stack trace:

                                                    at System.Deployment.Application.LockedFile.AcquireLock(String path, TimeSpan timeout, Boolean writer)

                                                    at System.Deployment.Application.SubscriptionStore.AcquireLock(DefinitionIdentity asmId, Boolean writer)

                                                    at System.Deployment.Application.SubscriptionStore.RefreshStorePointer()

                                                    at System.Deployment.Application.ApplicationActivator.PerformDeploymentActivation(Uri activationUri, Boolean isShortcut, String textualSubId, String deploymentProviderUrlFromExtension, BrowserSettings browserSettings, String& errorPageUrl)

                                                    at System.Deployment.Application.ApplicationActivator.ActivateDeploymentWorker(Object state)

     

    COMPONENT STORE TRANSACTION DETAILS

                    No transaction information is available.

     

    Thursday, February 17, 2011 3:36 PM
  • It looks like your application targets .NET 4. Can you turn on enhanced logging and pull the longer log file and post it here?

    http://robindotnet.wordpress.com/2010/05/31/enhanced-logging-in-clickonce-deployment/

    RobinDotNet


    Click here to visit my ClickOnce blog!
    Microsoft MVP, Client App Dev
    Thursday, February 17, 2011 6:05 PM
    Moderator
  • In my case it was issue related to profile corruption.

    We are able to fix the issue after recreating the user profile.

    Thursday, April 19, 2012 8:03 PM