Exception showing a erroneous web page in a WPF frame

Posted by H4mm3rHead on Stack Overflow See other posts from Stack Overflow or by H4mm3rHead
Published on 2010-03-08T20:06:03Z Indexed on 2010/05/27 10:51 UTC
Read the original article Hit count: 264

Filed under:

I have a small application where i need to navigate to an url, I use this method to get the Frame:

public override System.Windows.UIElement GetPage(System.Windows.UIElement container)
        {
            XmlDocument doc = new XmlDocument();
            doc.Load(Location);
            string webSiteUrl = doc.SelectSingleNode("website").InnerText;
            Frame newFrame = new Frame();
            if (!webSiteUrl.StartsWith("http://"))
            {
                webSiteUrl = "http://" + webSiteUrl;

            }
            newFrame.Source = new Uri(webSiteUrl);
            return newFrame;
        }

My problem is now that the page im trying to show generates a error (or so i think), when i load the page in a browser it never fully loads, keeps saying "loading1 element" in the load bar and the green progress line (IE 8) keeps showing. When i attach my debugger i get this error:

System.ArgumentException was unhandled
  Message="Parameter and value pair is not valid. Expected form is parameter=value."
  Source="WindowsBase"
  StackTrace:
       at MS.Internal.ContentType.ParseParameterAndValue(String parameterAndValue)
       at MS.Internal.ContentType..ctor(String contentType)
       at MS.Internal.WpfWebRequestHelper.GetContentType(WebResponse response)
       at System.Windows.Navigation.NavigationService.GetObjectFromResponse(WebRequest request, WebResponse response, Uri destinationUri, Object navState)
       at System.Windows.Navigation.NavigationService.HandleWebResponse(IAsyncResult ar)
       at System.Windows.Navigation.NavigationService.<>c__DisplayClassc.<HandleWebResponseOnRightDispatcher>b__8(Object unused)
       at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Boolean isSingleParameter)
       at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)
       at System.Windows.Threading.DispatcherOperation.InvokeImpl()
       at System.Threading.ExecutionContext.runTryCode(Object userData)
       at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Windows.Threading.DispatcherOperation.Invoke()
       at System.Windows.Threading.Dispatcher.ProcessQueue()
       at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
       at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
       at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
       at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Boolean isSingleParameter)
       at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Boolean isSingleParameter, Delegate catchHandler)
       ved System.Windows.Threading.Dispatcher.InvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Boolean isSingleParameter)
       at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
       at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
       at System.Windows.Threading.Dispatcher.TranslateAndDispatchMessage(MSG& msg)
       at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
       at System.Windows.Application.RunInternal(Window window)
       at GreenWebPlayerWPF.App.Main() i C:\Development\Hvarregaard\GWDS\GreenWeb\GreenWebPlayerWPF\obj\Debug\App.g.cs:linje 0
       at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
       at System.Threading.ThreadHelper.ThreadStart()
  InnerException: 

Anyone? Or any way to capture it and respond to it, tried a try/catch around my code, but its not caught - seems something deep inside the guts of the CLR is failing.

© Stack Overflow or respective owner

Related posts about wpf