XBAP脚本互操作失败
问题描述:
我在写一个小型的iframe托管的XBAP,需要与主机页面进行交互。 我首先写了一个小POC,看看我所需要的是否可能。XBAP脚本互操作失败
这里的页面构造函数的代码:
Public Sub New()
' This call is required by the designer.
InitializeComponent()
Try
Dim scriptObject = BrowserInteropHelper.HostScript
scriptObject.alert("blablabla")
Catch ex As Exception
MessageBox.Show(ex.ToString(), "Sign error", MessageBoxButton.OK, MessageBoxImage.Error)
End Try
End Sub
“警戒” 线抛出一个异常:
System.TypeAccessException: Attempt by method 'DynamicClass.CallSite.Target(System.Runtime.CompilerServices.Closure, System.Runtime.CompilerServices.CallSite, System.Object, System.Object ByRef)' to access type 'System.Runtime.CompilerServices.CallSite`1<Microsoft.VisualBasic.CompilerServices.IDOUtils+SiteDelegate1>' failed.
at CallSite.Target(Closure , CallSite , Object , Object&)
at Microsoft.VisualBasic.CompilerServices.IDOUtils.CreateRefCallSiteAndInvoke(CallSiteBinder Action, Object Instance, Object[] Arguments)
at Microsoft.VisualBasic.CompilerServices.IDOBinder.IDOCall(IDynamicMetaObjectProvider Instance, String MemberName, Object[] Arguments, String[] ArgumentNames, Boolean[] CopyBack, Boolean IgnoreReturn)
at SignVerify.Web.XBAP.Page1..ctor()
这发生在IE 64位,与IE的32位全XBAP无法加载(甚至在警报行之前)。
谢谢分配!
答
好吧,我明白我的错误。
本应该将应用程序标记为完全可信,这种方式完美。