none
FileLoadException after updating a ClickOnce application programmatically

    Question

  • Hi all:
    We are having an issue with an application that is being updated programmatically via ClickOnce (http://msdn.microsoft.com/en-us/library/ms404263.aspx).
    If the user quickly launches the application after doing the update and closing the application, the following exception appears:

    System.IO.FileLoadException: Could not load file or assembly 'ThirdPartyAssembly.dll' or one of its dependencies. The process cannot access the file because it is being used by another process. (Exception from HRESULT: 0x80070020)

    It seems to me that after the update, the DLLs do not get updated until the application is closed, and then if you launch the application during that process you get the error above.
    If the user waits long enough (a few seconds) after closing and then launch the application everything works fine.
    Any idea of what is causing this and how to avoid it?

    Daniel P
    Friday, September 30, 2011 7:51 PM

All replies

  • That method will let your application restart.

    And after the application started, you tried to close the application quickly, then the Exception was threw out, right? Is the proceeds is like what I understand from your post?

    If so, then the update proceed would be committed and finished, it is said that the probable cause is not here.

    You mean the file load exception is raised at application closing time, is it right?

    I have no more idea, if this is correct.

    If so, then I really would like to have a look at your Visual Studio project. Please upload it to the sky driver, and then share the download link in your post.

    And I also want you help me to ensure if the application can run well in others computer, to avoid some environment affect, such as a anti virus software maybe hold that assembly handle.

     

    If there's any concern, please feel free to let me know.

    Best wishes,


    Mike [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.

    Saturday, October 01, 2011 2:20 PM
  • Hi Mike:

    Thanks for taking a look at this. To answer your questions:

    Normally, the application updates correctly and everything is fine. After the update is done, we actually do not use Application.Restart(), we let the user know that the update is done and we suggest to close the application and launch it again (since it is a WPF application).

    We do this mainly because we do not want to reference the Windows.Forms assembly just to call Application.Restart(). Anyway, this shouldn't have to do anything with this issue, since it is the user who is manually "restarting" the application.

    The problem occurs trying to launch the application quickly after an update was performed and the application was closed.

    Additional information:

    • We have tried closing the application after an update, waiting 15-20 seconds and then launching, and it works perfectly.
    • We have tried not closing the application immediately after an update, but waiting several minutes, and then closing and launching it immediately (or 5 seconds) after. If we do this the exception mentioned before is thrown.

    We can reproduce this behavior in several computers, and our customers have experimented the issue before too. We are going to do some experimentation turning off any anti-virus and come back to you.

    Thanks.


    Daniel P

    Monday, October 03, 2011 10:00 PM
  • I would like to listen your result after you tried to turn off the anti virus software.

    And it is also looks like the process has not been exited completely, so that the file it reference also handled by that process, this let the other process cannot load it.


    Mike [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.

    Wednesday, October 05, 2011 5:03 AM
  • I am writing to check the status of the issue on your side. 
    What about this problem now? 
    Would you mind letting us know the result of the suggestions?

    Mike [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.

    Friday, October 07, 2011 3:57 AM
  • Hi Mike:

    The problem occurs also on clean Windows installs where there's no anti-virus or anything else.

    To respond to your question about process not exiting completely. The application process itself exits immediately when closing (confirmed via task manager), as I mentioned the issue occurs only after an update via ClickOnce.

    Thanks.


    Daniel P
    Tuesday, October 11, 2011 8:16 PM
  • Can you provide your this project or your product? I would like to have a try to see if I can reproduce this issue in my local side.
    Mike [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.

    Wednesday, October 12, 2011 5:14 PM
  • I can't provide you with the project (it's huge and it uses several 3rd party components), but I can give you a link to download the application though if you provide me your e-mail address.
    Daniel P
    Wednesday, October 12, 2011 9:25 PM
  • windows7dos@hotmail.com

    This is my email address.

     


    Mike [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.


    Thursday, October 13, 2011 3:12 PM
  • Hi daniel,

    I had installed your product on my pc, and sent you the response, but there's no response form you.

    Can you show me the status on your side?

     

    Best wishes,


    Mike [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.

    Thursday, October 27, 2011 4:02 AM