Search code examples
c#silverlight-4.0windows-7silverlight-oobsilverlight-plugin

Plugin crashes on refreshing page from app on Win 7


I have a page with Silverlight 4 oob app. After app is installed the bage on the page should automatically refresh. I tried calling the scripts or simple Document.Submit from code on InstallStateChanged - and they all worked well on win XP (not only on my machine), but on Win 7 or Vista the page hangs or even silverlight plugin crashes before the installation beginning. However without refresh function on the installation process flows smoothly. How should I do the correct refresh for those systems? The info why this can happen will be helpful too.

    public App ()
    {
        this.Startup += this.Application_Startup;
        this.Exit += this.Application_Exit;
        this.UnhandledException += this.Application_UnhandledException;

        InitializeComponent();

        App.Current.InstallStateChanged += (s, c) => HtmlPage.Document.Submit(); //used that as the most common used example
    }

    private void Application_Startup (object sender, StartupEventArgs e)
    {
        if (Application.Current.IsRunningOutOfBrowser)
        {
            this.RootVisual = new MainPage();
        } else if (Application.Current.InstallState == InstallState.Installed)
        {
            this.RootVisual = new InstalledPage();
        } else
        {
            this.RootVisual = new InstallPage();
        }
    }

Where MainPage and installedPage are simple grids with text field. Install Page contains only button with click event - to install the App. The web page is auto generated one. Nothing more. Still on Win 7 and Vista have the same prob while install as they had.

UPD: project files


Solution

  • I have changed your test case like this:

    public App () {
            ...
    
        App.Current.InstallStateChanged += new EventHandler(Current_InstallStateChanged);
    }
    
    void Current_InstallStateChanged(object sender, EventArgs e) {
        if(App.Current.InstallState == System.Windows.InstallState.Installed) {
            HtmlPage.Document.Submit();
        }
    }
    

    And it refreshes upon install on windows 7 fine.