如何在xbap和javascript之间进行通信?

时间:2017-07-10 07:11:16

标签: javascript .net wpf xbap

Error image您好我有一个xbap应用程序和Web应用程序。我的xbap托管于scanner.aufait.in,网络应用程序托管于webapp.aufait.in。我已经使用clickonce部署了xbap并且它正在运行。我正在使用iframe访问它。我试图将一些数据从xbap传递给javascript。

 private async void Button_Click_3(object sender, RoutedEventArgs e)
        {
             var filename="Passport";
             var hostScript BrowserInteropHelper.HostScript.setTimeout("WorkDamnit()", 0);
             hostScript.document.ResponseData(filename);
        }

我的html代码中有以下javascript。

<!DOCTYPE ...>
<head>
    <script type="text/javascript">
        document.ResponseData = function (responseData) {
            window.opener.ResponseAlert(responseData);
            window.close();
        }
    </script>
    <meta name="viewport" content="width=device-width" />
    <meta http-equiv="X-UA-Compatible" content="IE=8" />  
    <title>ScannerView</title>
</head>
<body>
    <div>
        <iframe src="http://Scanner.aufytech.com/C3CKYC Scanner.xbap?

Param=@ViewBag.FileName" width="1000" height="600" scrolling="auto"></iframe>
    </div>
</body>
</html>

按下xbap的按钮事件后,我想将文件名返回到html,如下所示。

 window.ResponseAlert = function (responseData) {
  console.log(responseData);
}

当我点击xbap按钮时,我收到错误

Microsoft.CSharp.RuntimeBinder.RuntimeBinderException:无法对空引用执行运行时绑定

我附加了错误的屏幕截图。我无法确定我面临此错误的位置和原因?任何帮助非常感谢。谢谢。

0 个答案:

没有答案