4

I'm working on a cool C# app, which uses JS a lot for our model layer. We would like to use the IE9 Chakra Javascript engine for speed improvements.

Questions:

  • Can I use Chakra in C#, and interact with JS objects as COM objects? (to call functions on JS objects)
  • Can I install Chakra separately from IE9? (some users do not have IE9 installed, so it would be easier if they did not have to install IE9, but just Chakra).

Thanks a lot in advance for you expertise.

Cheeso
  • 180,104
  • 92
  • 446
  • 681
Bodekaer
  • 226
  • 2
  • 15

2 Answers2

7

Answer to Q#1

Yes, you can interact with Javascript logic running in Chakra from C# via COM.

in Particular, from a c# program, you can startup Chakra via IActiveScript, load some Javascript/ES5 code into it, then invoke methods defined in that Javascript code via a COM IDispatch pointer.

Related:

Answer to Q#2

As far as I know, NO, you cannot install Chakra without installing IE9. You can design your C# app, though, to gracefully degrade to use the existing JScript engine, for computers without Chakra.

Community
  • 1
  • 1
Cheeso
  • 180,104
  • 92
  • 446
  • 681
  • Can you please help me with this question :https://stackoverflow.com/questions/48150043/getting-unable-to-load-chakra-core-dll-error-while-running-hello-world-sample – ILoveStackoverflow Jan 08 '18 at 12:56
2

[Update] Based on Cheeso's answer it seems you can use IE9's JS engine[/Update]. However I found that V8 JavaScript engine (Chrome's JS engine) mentions that you can use V8 engine in you C++ application. Follow V8 embedder's guide to find out more. I did not find any reference where they mentioned exposing V8 functionality through COM interface, so you might not be able to use it from C#.

Pradeep
  • 3,174
  • 1
  • 19
  • 34
  • Bump. Any news about this? Have you heard any updates from MS about the possibility for this in the future? – Bodekaer Aug 13 '11 at 03:41
  • No, I don't have any such information. Have you checked http://projects.nikhilk.net/ScriptSharp? Would that be useful to you? – Pradeep Aug 14 '11 at 19:56
  • This answer is wrong. It *is possible* to interact with the IE9 JS engine. See my answer. http://stackoverflow.com/questions/5429749/c-ie9-js-engine-chakra/7433549#7433549 – Cheeso Sep 18 '11 at 20:28