DynamicObjects don't register with RegisterJsObject with Chromium / CefSharp

混江龙づ霸主 提交于 2019-12-25 16:04:33

问题


I created a dynamic object and try to register it with RegisterJsObject. However, the javascript code on the client side doesn't recongize the register js object and I can't call any of the functions that are par tof the dynamic object.

Ex.

C# code:

dynamic obj = new ExpandoObject();
obj.FullName = new Action(() =>
{
   Console.WriteLine("FullName method called");
});

Cef.Initialize(new CefSettings());
ChromiumWebBrowser browser = new ChromiumWebBrowser("");
browser.RegisterJsObject("pesonObj", obj);

Javascript Code

personObj.fullName();

Even when I examine the javascript object personObj in a developer's console, it doesn't have the fullName function.

If I create a normal class that isn't dynamic, this isn't the case and works as expected.

So the question is, does Chromium support dynamicObject for registering as javascript objects in the embedded browser.

Any advice appreciated, Thanks, D

来源:https://stackoverflow.com/questions/36489890/dynamicobjects-dont-register-with-registerjsobject-with-chromium-cefsharp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!