locked
Does CheckAndDownloadUpdateAsync() method works only in OOB? RRS feed

  • Question

  • I am working on a Silverlight 4 application which is not OOB enabled. In this situation how can i use CheckAndDownloadUpdateAsync() to check and update application XAP file?

    Tuesday, November 20, 2012 3:10 PM

Answers

  • Hi SL User,

    Unfortunately, it seems works only in OOB.

    If you look into the source code of CheckAndDownloadUpdateAsync method (assembly: C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\Silverlight\v5.0\System.Windows.dll) by using reflector, you will see:

    public void CheckAndDownloadUpdateAsync()
    {
        XcpImports.Application_CheckAndDownloadUpdate(this);
    }
    [SecuritySafeCritical]
    internal static void Application_CheckAndDownloadUpdate(Application app)
    {
        CheckThread();
        CheckHResult(Application_CheckAndDownloadUpdateNative(((IManagedPeerBase) app).NativeObject));
        GC.KeepAlive(app);
    }
    [SecuritySafeCritical]
    internal static void CheckThread()
    {
        if (Thread.CurrentThread.ManagedThreadId != JoltHelper.ThreadID)
        {
            throw new UnauthorizedAccessException(Resx.GetString("InvalidCrossThreadAccess"));
        }
    }

    I tested it, when I call the method, it will not throw any exception, and the CheckAndDownloadUpdateCompleted is never executed. But when I run it in OOB mode, everything works fine as expected.

    Best Regards


    Please mark the replies as answers if they help or unmark if not. If you have any feedback about my replies, please contact msdnmg@microsoft.com Microsoft One Code Framework

    Thursday, November 22, 2012 12:54 PM
    Moderator

All replies

  • Hi SL User,

    Unfortunately, it seems works only in OOB.

    If you look into the source code of CheckAndDownloadUpdateAsync method (assembly: C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\Silverlight\v5.0\System.Windows.dll) by using reflector, you will see:

    public void CheckAndDownloadUpdateAsync()
    {
        XcpImports.Application_CheckAndDownloadUpdate(this);
    }
    [SecuritySafeCritical]
    internal static void Application_CheckAndDownloadUpdate(Application app)
    {
        CheckThread();
        CheckHResult(Application_CheckAndDownloadUpdateNative(((IManagedPeerBase) app).NativeObject));
        GC.KeepAlive(app);
    }
    [SecuritySafeCritical]
    internal static void CheckThread()
    {
        if (Thread.CurrentThread.ManagedThreadId != JoltHelper.ThreadID)
        {
            throw new UnauthorizedAccessException(Resx.GetString("InvalidCrossThreadAccess"));
        }
    }

    I tested it, when I call the method, it will not throw any exception, and the CheckAndDownloadUpdateCompleted is never executed. But when I run it in OOB mode, everything works fine as expected.

    Best Regards


    Please mark the replies as answers if they help or unmark if not. If you have any feedback about my replies, please contact msdnmg@microsoft.com Microsoft One Code Framework

    Thursday, November 22, 2012 12:54 PM
    Moderator
  • Thanks much for your reply.

    In this situation is there any alternate solution to check and update the XAP file?

    Friday, November 23, 2012 7:09 AM
  • Hi, here is my idea.

    1. Download the .xap file in the Application_Startup event by using WebClient;         http://msdn.microsoft.com/en-us/library/cc189021(v=vs.95).aspx
    2. Compare the version of downloaded xap file with current app;         http://social.msdn.microsoft.com/Forums/en-US/silverlightstart/thread/ac900ee2-2f7e-4af5-b657-767b93e7453f
    3. Install it if it is newer. (Just refresh current embed page) 

    Hope it will help you.

    Best Regards


    Please mark the replies as answers if they help or unmark if not. If you have any feedback about my replies, please contact msdnmg@microsoft.com Microsoft One Code Framework

    Friday, November 23, 2012 7:39 AM
    Moderator