日期:2014-05-17  浏览次数:20901 次

WPF WebBrowser应用程序使用WebBrowser出错
在WPFWebBrowserApplication中,使用WebBrowser控件,给给Source属性赋值后,会出现如下问题:

您正在使用的应用程序中出现错误。
您可以尝试以下方法:
重新启动应用程序。 
有关此错误的详细信息,请单击下面的“详细信息”链接。 
 较少信息 

启动 URI: E:\Work\Test\WPFTest\WPFBrowser\bin\Debug\WPFBrowser.xbap
应用程序标识: file:///E:/Work/Test/WPFTest/WPFBrowser/bin/Debug/WPFBrowser.xbap#WPFBrowser.xbap, Version=1.0.0.0, Culture=neutral, PublicKeyToken=c6b627854ade35d6, processorArchitecture=msil/WPFBrowser.exe, Version=1.0.0.0, Culture=neutral, PublicKeyToken=c6b627854ade35d6, processorArchitecture=msil, type=win32

System.Reflection.TargetInvocationException: 调用的目标发生了异常。
---> System.Reflection.TargetInvocationException: 调用的目标发生了异常。
---> System.Security.SecurityException: 请求“System.Net.WebPermission, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089”类型的权限已失败。
  在 System.Security.CodeAccessSecurityEngine.Check(Object demand, StackCrawlMark& stackMark, Boolean isPermSet)
  在 System.Security.CodeAccessSecurityEngine.Check(CodeAccessPermission cap, StackCrawlMark& stackMark)
  在 System.Security.CodeAccessPermission.Demand()
  在 MS.Internal.SecurityHelper.DemandWebPermission(Uri uri)
  在 System.Windows.Controls.WebBrowser.DoNavigate(Uri source, Object& targetFrameName, Object& postData, Object& headers, Boolean ignoreEscaping)
  在 System.Windows.Controls.WebBrowser.set_Source(Uri value)
  --- 内部异常堆栈跟踪的结尾 ---
  在 System.RuntimeMethodHandle._InvokeMethodFast(IRuntimeMethodInfo method, Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeType typeOwner)
  在 System.RuntimeMethodHandle.InvokeMethodFast(IRuntimeMethodInfo method, Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeType typeOwner)
  在 System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
  在 System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
  在 System.Xaml.Schema.XamlMemberInvoker.SetValueSafeCritical(Object instance, Object value)
  在 System.Xaml.Schema.XamlMemberInvoker.SetValue(Object instance, Object value)
  在 MS.Internal.Xaml.Runtime.ClrObjectRuntime.SetValue(XamlMember member, Object obj, Object value)
  在 MS.Internal.Xaml.Runtime.ClrObjectRuntime.SetValue(Object inst, XamlMember property, Object value)
  在 System.Xaml.XamlObjectWriter.SetValue(Object inst, XamlMember property, Object value)
  在 System.Xaml.XamlObjectWriter.Logic_ApplyPropertyValue(ObjectWriterContext ctx, XamlMember prop, Object value, Boolean onParent)
  在 System.Xaml.XamlObjectWriter.Logic_DoAssignmentToParentProperty(ObjectWriterContext ctx)
  在 System.Xaml.XamlObjectWriter.Logic_AssignProvidedValue(ObjectWriterContext ctx)
  在 System.Xaml.XamlObjectWriter.WriteEndMember()
  在 System.Xaml.XamlWriter.WriteNode(XamlReader reader)
  在 System.Windows.Markup.WpfXamlLoader.TransformNodes(XamlReader xamlReader, XamlObjectWriter xamlWriter, Boolean onlyLoadOneNode, Boolean skipJournaledProperties, Boolean shouldPassLineNumberInfo, IXamlLineInfo xamlLineInfo, IXamlLineInfoConsumer xamlLineInfoConsumer, XamlContextStack`1 stack, IStyleConnector styleConnector)
  在 System.Windows.Markup.WpfXamlLoader.Load(XamlReader xamlReader, IXamlObjectWriterFactory writerFactory, Boolean skipJournaledProperties, Object rootObject, XamlObjectWriterSettings settings, Uri baseUri)
  在 System.Windows.Markup.WpfXamlLoader.LoadBaml(XamlReader xamlReader, Boolean skipJournaledProperties, Obje