当前位置: 首页 > news >正文

浏览器CEFSharp88+X86+win7 之js交互开启(五)

编写

 灵体.JavascriptObjectRepository.Settings.LegacyBindingEnabled = true;

错误提醒

关调用实时(JIT)调试而不是此对话框的详细信息,
请参见此消息的结尾。

************** 异常文本 **************
System.Exception: JavascriptBindingSettings.LegacyBindingEnabled can no longer be modified, settings must be changed before the underlying browser has been created.
在 CefSharp.Internals.FreezableBase.ThrowIfFrozen(String memberName)
在 CefSharp.JavascriptBinding.JavascriptBindingSettings.set_LegacyBindingEnabled(Boolean value)
在 CyberWin.NET.Csharp.WebBrowser.Form_老多tab.东方仙盟_赋值接口(ChromiumWebBrowser 灵体)
在 CyberWin.NET.Csharp.WebBrowser.Form_老多tab.NewTab(String startUrl)
在 CyberWin.NET.Csharp.WebBrowser.Form_老多tab.toolStripButton8_Click(Object sender, EventArgs e)
在 System.Windows.Forms.ToolStripItem.RaiseEvent(Object key, EventArgs e)
在 System.Windows.Forms.ToolStripButton.OnClick(EventArgs e)
在 System.Windows.Forms.ToolStripItem.HandleClick(EventArgs e)
在 System.Windows.Forms.ToolStripItem.HandleMouseUp(MouseEventArgs e)
在 System.Windows.Forms.ToolStripItem.FireEventInteractive(EventArgs e, ToolStripItemEventType met)
在 System.Windows.Forms.ToolStripItem.FireEvent(EventArgs e, ToolStripItemEventType met)
在 System.Windows.Forms.ToolStrip.OnMouseUp(MouseEventArgs mea)
在 System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
在 System.Windows.Forms.Control.WndProc(Message& m)
在 System.Windows.Forms.ScrollableControl.WndProc(Message& m)
在 System.Windows.Forms.ToolStrip.WndProc(Message& m)
在 System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
在 System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
在 System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)


************** 已加载的程序集 **************
mscorlib
程序集版本:4.0.0.0
Win32 版本:4.8.4795.0 built by: NET48REL1LAST_B
基本代码:file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/mscorlib.dll
----------------------------------------
CyberWin.NET.ApplicationVOS109
程序集版本:1.0.0.0
Win32 版本:1.0.0.0
基本代码:file:///G:/%E6%9C%AA%E6%9D%A5%E4%B9%8B%E7%AA%97%E6%BA%90%E7%A0%81%E5%A4%87%E4%BB%BD/visaulstudio/CyberWin.NET.ApplicationVOS109/packages/%E6%9C%AA%E6%9D%A5%E4%B9%8B%E7%AA%9788%E6%89%93%E5%8C%85/CyberWin.NET.ApplicationVOS109.exe
----------------------------------------
System.Windows.Forms
程序集版本:4.0.0.0
Win32 版本:4.8.4739.0 built by: NET48REL1LAST_B
基本代码:file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Windows.Forms/v4.0_4.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
----------------------------------------
System

在使用诸如 CefSharp(一个用于在.NET 应用程序中嵌入 Chromium 浏览器的库)之类的框架时,你提到的代码 webview.JavascriptObjectRepository.Settings.LegacyBindingEnabled = true; 具有以下含义:

  1. JavascriptObjectRepository:这是 CefSharp 中用于管理在 JavaScript 和.NET 之间共享对象的存储库。通过这个存储库,你可以将.NET 对象暴露给 JavaScript 代码,使得 JavaScript 能够调用.NET 对象的方法、访问其属性等,实现双向通信。

  2. Settings:它表示 JavascriptObjectRepository 的设置集合,其中包含了各种配置选项,用于控制对象绑定的行为。

  3. LegacyBindingEnabled:这是 Settings 中的一个布尔属性。当设置为 true 时,它启用了旧版绑定模式。在旧版绑定模式下:

    • 命名约定:JavaScript 访问.NET 对象的属性和方法时,使用的命名约定相对简单直接。例如,如果有一个.NET 类 MyClass 具有属性 MyProperty 和方法 MyMethod,在 JavaScript 中可以直接以相同的名称访问它们。
    • 兼容性:这种模式有助于与旧版代码或不严格遵循最新最佳实践的代码保持兼容性。例如,一些早期编写的 JavaScript 代码可能依赖于这种简单的命名映射来与.NET 对象进行交互。

然而,启用旧版绑定模式也可能带来一些潜在的问题,例如可能存在命名冲突的风险,并且从长远来看,可能不符合最新的安全或设计标准。在新的开发中,可能更推荐使用更现代、安全和灵活的绑定方式,但在某些特定场景下,启用此选项可以解决兼容性问题。

总之,这行代码的作用是启用 JavascriptObjectRepository 的旧版绑定模式,以便 JavaScript 能够以特定的旧版方式与.NET 对象进行交互

阿雪技术观
在科技发展浪潮中,我们不妨积极投身技术共享。不满足于做受益者,更要主动担当贡献者。无论是分享代码、撰写技术博客,还是参与开源项目维护改进,每一个微小举动都可能蕴含推动技术进步的巨大能量。东方仙盟是汇聚力量的天地,我们携手在此探索硅基生命,为科技进步添砖加瓦。

Hey folks, in this wild tech - driven world, why not dive headfirst into the whole tech - sharing scene? Don't just be the one reaping all the benefits; step up and be a contributor too. Whether you're tossing out your code snippets, hammering out some tech blogs, or getting your hands dirty with maintaining and sprucing up open - source projects, every little thing you do might just end up being a massive force that pushes tech forward. And guess what? The Eastern FairyAlliance is this awesome place where we all come together. We're gonna team up and explore the whole silicon - based life thing, and in the process, we'll be fueling the growth of technology.

http://www.lryc.cn/news/616207.html

相关文章:

  • 深入理解C语言一维数组的本质:数组名、指针常量与访问细节
  • 女子试穿4条裤子留下血渍赔50元引争议:消费责任边界在哪?
  • 无须炮解,打开即是Pro版
  • (LeetCode 每日一题) 869. 重新排序得到 2 的幂 (哈希表+枚举)
  • Python中随机化列表元素的详细方法
  • LintCode第604题-滑动窗口内数的和
  • DAY36打卡
  • 自创论述类文本阅读:论温泉
  • ubuntu 安装内核模块驱动 DKMS 介绍
  • 基于Ubuntu20.04的环境,编译QT5.15.17源码
  • ubuntu22.04+samba
  • 正则表达式常用语法参考
  • 零基础学Java第三讲---运算符
  • CSS优先级、HTTP响应状态码
  • ​Microsoft Store 离线下载软件
  • Unity笔记(四)——Camera、碰撞检测函数、刚体加力、音频
  • 电脑使用“碎片整理”程序的作用
  • Java I/O 流:从字节流到 NIO 的进化与应用
  • idea中使用maven造成每次都打印日志
  • IDEA官网下载及其他版本软件下载地址
  • Ubuntu 安装 Elasticsearch
  • 【0基础PS】PS工具详解--缩放工具
  • 【python】import与include的区别
  • 运维学习Day20——MariaDB数据库管理
  • 生产环境中Spring Cloud Sleuth与Zipkin分布式链路追踪实战经验分享
  • LeetCode_哈希表
  • 【代码随想录day 16】 力扣 112. 路径总和
  • Java学习第一百二十三部分——HTTP/HTTPS
  • 一文学习nacos和openFeign
  • MariaDB 数据库管理