ApplicationDeployment.CurrentDeployment returning Object reference not set to an instance of an object

Answered ApplicationDeployment.CurrentDeployment returning Object reference not set to an instance of an object

  • Thursday, September 13, 2012 5:36 AM
     
     

    This a VisualStudio 2010 project. Running .net2. We've been running this app for years - it's got a custom update logic built in. We do this check:

     if (ApplicationDeployment.IsNetworkDeployed) {

                    ApplicationDeployment ad = ApplicationDeployment.CurrentDeployment;

                    try {

                        info = ad.CheckForDetailedUpdate();

                    } catch (Exception e) {

    ...

    We'll catch exceptions - if the client is not connected to a network, etc. If there is an update, we do the update, show a progress bar and restart the client. This has worked for years. Just recently, we did an update - of our clients, almost all of them (about 90%) are suddenly not working and not updated. I've been able to reproduce on one of my local laptops. What I've learned is - the code runs past the IsNetworkDeployed stage as normal, but the next line -  ApplicationDeployment.CurrentDeployment is returning null. Looking at the API - it should never return null. Thus, the error we're seeing. The issue is - I can't update these clients. It appears random - there's no pattern on why some worked and others have not. We've done subsequent releases and the clients that work, seem to get their updates - the ones not working continue to not work. In once case - I saw the logs that showed this failing  - but then finally working. So, I'm not sure if it's random totally, or what's at play. I have no way of debugging this code myself - it's happening in the MS code. We have hundreds of these clients so we heavily rely on the clickonce funtionality and it has worked for a long time. If there's any ideas on why the ApplicationDeployment is not working and what we may be able to try - please let me know. i'm looking at opening a support ticket as well, but thought we'd try this first. 


All Replies

  • Monday, September 17, 2012 4:06 AM
    Moderator
     
     

    Hi Tragiccc,

    I have searched document and don't find any situation the CurrentDeployment is null. The IsNetworkDeployed property is used to ensure CurrentDeployment reference is not null.

    Have you changed some settings of the project? Will the problem exist if you update to the last successful version?

    If there are any new findings, please feel free to let us know.

    Best regards,


    Chester Hong
    MSDN Community Support | Feedback to us
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

  • Thursday, September 20, 2012 6:32 PM
     
     Answered

    We've solved the issue. Here's what happened. We had built the app with the with the Platform target set to "Any CPU". All our clients were on 32bit. We had some move to 64bit and the app would not work. We had learned that one of the included DLLs was compiled in 32bit, so we had to modify this from "Any CPU" to "x86". This solved the issue where 64 bit users could download the app, but all others were not getting updated due to the error described above. Once we moved the app back to "Any CPU", we republished, uploaded the app, all the users were able to get the new version. Of course, 64 bit users will not be able to. We'll need to make two versions of the app in the short term, until we can re-install all the clients with versions built with x64.

    We talked to MS support about this. Their initial reaction - okay, makes sense. But - I think it's still a bug. It should not simply return a NPE when accessing the object. An exception with some information in it would be helpful.