Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > Avalon

Vista - timer causes crash with frame targeting web

 
 
Old 09-26-2008   #1 (permalink)
ormico


 
 

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
Old 09-26-2008   #2 (permalink)
ormico


 
 

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
 

Thread Tools


Similar Threads
Thread Forum
Privacy Groups Urge Curbs on Online Targeting Chillout Room
Microsoft Confirms Attacks Targeting Critical 0-Day Office Excel Vulnerability System Security
RC2 Egg Timer Vista General
Microsoft Launches Enforcement Campaign Targeting Web Site “Cybersquatters” Who Use Online Ads Vista News


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46