Expose a .NET Object to Javascript?

135 views
Skip to first unread message

Christian LeMoussel

unread,
Mar 29, 2015, 10:48:50 AM3/29/15
to cefs...@googlegroups.com
I've seen about this this CefSharp FAQ  How do you expose a .NET class to Javascript?

Can I create an object like  Dictionary<string, string>  in .NET and access it from my JavaScript code?

Alex Maitland

unread,
Mar 29, 2015, 5:26:46 PM3/29/15
to cefs...@googlegroups.com

Christian LeMoussel

unread,
Mar 30, 2015, 1:34:06 AM3/30/15
to cefs...@googlegroups.com
One idea when this pull request  Feature/register object using a dictionary #893  was committed?
Actually with CefSharp V 39.0.0.0, I got this JavaScript Error

CEF Console:
------------
Uncaught ReferenceError: bound is not defined


With this C# Code

            Dictionary<string, string> hcT = new Dictionary<string, string>{ {"prop1", "value1"}, {"prop2", "value2"} };
           
Browser.RegisterJsObject("bound", hcT);

and JS Code

console.log(bound);


Alex Maitland

unread,
Mar 30, 2015, 2:07:20 AM3/30/15
to cefs...@googlegroups.com
When you look closely at the PR, you'll see that it's status is `Open`.

Christian LeMoussel

unread,
Mar 30, 2015, 3:40:57 AM3/30/15
to cefs...@googlegroups.com
Yep. Ok Alex.
Did you know the reason / the difficulty why this request is not committed?


Alex Maitland

unread,
Mar 30, 2015, 4:16:02 AM3/30/15
to cefs...@googlegroups.com
Lack of hours in the day :)

Alex Maitland

unread,
Mar 30, 2015, 4:16:23 AM3/30/15
to cefs...@googlegroups.com
Feel free to take it for a spin and report back.

Christian LeMoussel

unread,
Mar 30, 2015, 2:00:52 PM3/30/15
to cefs...@googlegroups.com
I use CefSharp library via Nuget.
I'll see to download the master branch on GitHub and merge request  #893 (2 files changed) to test it & report back.

Christian LeMoussel

unread,
Mar 31, 2015, 1:22:15 PM3/31/15
to cefs...@googlegroups.com
Alex I reported back (LeMoussel) on https://github.com/cefsharp/CefSharp/pull/893
Reply all
Reply to author
Forward
0 new messages