Passing JS Object back into C#

856 views
Skip to first unread message

James Lamanna

unread,
Jan 28, 2013, 12:10:11 PM1/28/13
to cefs...@googlegroups.com
Hi,
Is there a way to pass a JS Object back into C# that's not a dictionary, string, integer, etc..?
I'm trying to use CEFSharp for hosting the Google Earth Plugin, and using C# bindings to the GEPlugin API, but I need a way to get the IGEPlugin object into C#.
The default C# WebBrowser lets me do this because I can specify a function with an 'object' type parameter, but I can't seem to do that with CEFSharp.

Thanks.

James Lamanna

unread,
Jan 28, 2013, 12:19:39 PM1/28/13
to cefs...@googlegroups.com
I should also say I can use a method with prototype void(object o) in C#, except the parameter is always null.

-- James

James Lamanna

unread,
Jan 28, 2013, 1:39:18 PM1/28/13
to cefs...@googlegroups.com
It looks like the main issue is that CEFSharp has no way to pass a generic object back to C#, through RegisterJSObject or EvaluateScript.
This is a big problem for me and my application.

-- James

anthony taranto

unread,
Jan 28, 2013, 2:46:35 PM1/28/13
to cefs...@googlegroups.com
One of the forks on GitHub had some experimental code to covert arbitrary objects between js and c#. Obviously, that approach is going to be somewhat error prone. If there's any way for you to limit the cross language barrier in your application to primitives, your life will be much easier.

--Anthony

--
You received this message because you are subscribed to the Google Groups "CefSharp" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cefsharp+u...@googlegroups.com.
To post to this group, send email to cefs...@googlegroups.com.
Visit this group at http://groups.google.com/group/cefsharp?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

James Lamanna

unread,
Jan 28, 2013, 3:06:42 PM1/28/13
to cefs...@googlegroups.com
Hi Anthony,
Unfortunately in the Google Earth Plugin case its unavoidable.
The initialize functions give you back a COM object in JS that I need to marshal into C# somehow.

-- James

James Lamanna

unread,
Jan 28, 2013, 3:17:21 PM1/28/13
to cefs...@googlegroups.com
Also where are those forks on GitHub?
Are they in a different project because I don't see any additional branches in the CefSharp GitHub repo.

-- James

anthony taranto

unread,
Jan 28, 2013, 3:31:45 PM1/28/13
to cefs...@googlegroups.com
Branches and forks are two separate things:

https://github.com/ataranto/CefSharp/network

To unsubscribe from this group, send email to cefsharp+u...@googlegroups.com.

Jack O'Connor

unread,
Jan 28, 2013, 4:08:47 PM1/28/13
to cefs...@googlegroups.com
James, I'm not familiar with how the GEPlugin works, but one thing you could consider is using ExecuteScript from C# to talk to it. You can do that in an ad-hoc way if your not calling too many functions, or you might set up a sort of pub-sub event model that uses ExecuteScript and RegisterJsObject to marshal events back and forth.
Reply all
Reply to author
Forward
0 new messages