I'm writing a small iframe-hosted XBAP that needs to interact with the host page.
I've first wrote a small POC to see that all I need is possible.
Here's the code of the page constructor:
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
The "alert" line throws next exception:
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()
This happens in IE 64-bit, with IE 32-bit the whole XBAP fails to load (even before the alert line).
Thanks allot!
OKay, I've understood my mistake.
Should have marked the application as full-trust, this way it works perfectly.