Windows Vista Forums

timer causes crash with frame targeting web

  1. #1


    ormico Guest

    timer causes crash with frame targeting web

    I posted this at microsoft.public.dotnet.framework before I found the Avalog
    newsgroup, but I didn't get any helpful responses yet. If anyone has an idea
    what my problem might be, let me know what you think or what I might try.

    I have a small WPF application that has a frame that points to a web page on
    the internet.

    I also have a System.Timer.Timer that goes off after 1 minute. If I try to
    modify an object on the page it generates an error and crashes the program.
    This is an error that I cannot catch with a try catch block. It crashes the
    program anyway and prompts me to send the crash info to microsoft.

    What I am ultimatly try to accomplish is an application that displays a web
    page for a certain amount of time, then closes. I would like to put this in
    an appdomain that gets reloaded after it closes each time. This is because
    when the web page runs for a while in IE it will consume more and more
    memory. I want to be able to unload the page wit the web browser control to
    free the memory and then reopen and go back to the page. Most of this is
    working but I can't get the wpf page with the webbrowser control to close
    after a certain amount of time because when I call this.Close() or
    Application.Current.Shutdown() it crashes. I get the same behavior if I try
    to access any other controls also.

    The error I recieved, as stated in the original post, is the Windows Crash
    dialog that prompts you to send the error information to Microsoft. If you
    click "What does this error report containt?" you are presented with an Error
    Signature. The only part that looks useful is "P9 :
    system.missingmethodexception"

    Code Sample:
    Please note in the example below that I do not try do do anything with the
    exception except catch it.
    This is to be sure that I'm not introducing the exception in the catch block.

    class Startup
    {
    [STAThread()]
    [LoaderOptimization(LoaderOptimization.MultiDomainHost)]
    static void Main()
    {
    // AppDomain code commented out.
    //CrossAppDomainDelegate action = () =>
    //{
    // App app = new App();
    // app.MainWindow = new Window1();
    // app.MainWindow.Show();
    // app.Run();
    //};

    //for (int i = 0; i < 10; i++)
    //{
    // try
    // {
    // AppDomain domain = AppDomain.CreateDomain("another domain");
    // domain.DoCallBack(action);
    // }
    // catch (Exception ex)
    // {
    // }
    //}

    try
    {
    App app = new App();
    app.MainWindow = new Window1();
    app.MainWindow.Show();
    app.Run();
    }
    catch (Exception)
    {

    }
    }
    }

    <Window x:Class="WpfWebBrowser.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="Window1" Height="800" Width="1118" WindowState="Maximized">
    <Grid Name="grMain">
    <Frame Name="frmDisplay" NavigationUIVisibility="Visible"
    Margin="0,0,0,50" Source="http://example.com/" />
    <Button Name="btRefresh" Width="100" Height="32"
    Click="btRefresh_Click" HorizontalAlignment="Left" Margin="12,0,0,12"
    VerticalAlignment="Bottom">0</Button>
    <Button Name="btClose" Width="100" Height="32" Click="btClose_Click"
    HorizontalAlignment="Left" Margin="118,0,0,12"
    VerticalAlignment="Bottom">Close</Button>
    </Grid>
    </Window>

    public partial class Window1 : Window
    {
    public Window1()
    {
    InitializeComponent();

    timer2 = new System.Threading.Timer(timer2_Callback);
    timer2.Change((int)(TimeSpan.FromMinutes(1.0).TotalMilliseconds), 0);
    }

    void timer2_Callback(object state)
    {
    try
    {
    this.Dispatcher.Invoke((Action)(delegate()
    {
    btRefresh.Content = "blah";
    }));
    }
    catch (Exception)
    {

    }
    }

    System.Threading.Timer timer2 = null;

    private void btRefresh_Click(object sender, RoutedEventArgs e)
    {
    frmDisplay.Navigate(new Uri("http://example.com/"));
    }

    private void btClose_Click(object sender, RoutedEventArgs e)
    {
    this.Close();
    }
    }



      My System SpecsSystem Spec

  2.   


  3. #2


    ormico Guest

    RE: timer causes crash with frame targeting web

    I should add that clicking the Close button closes the window with no error.

      My System SpecsSystem Spec


timer causes crash with frame targeting web

Similar Threads
Thread Forum
What Version of Win 7 Are You Targeting? .NET General
Privacy Groups Urge Curbs on Online Targeting Chillout Room
Microsoft Confirms Attacks Targeting Critical 0-Day Office Excel Vulnerability System Security
Multi - targeting not working properly. Avalon
Microsoft Launches Enforcement Campaign Targeting Web Site “Cybersquatters” Who Use Online Ads Vista News