2

I am trying to run chakra core c# sample provided here(https://github.com/Microsoft/ChakraCore/wiki/Embedding-ChakraCore#before-you-start) but getting error :enter image description here

I tried to install this also but getting error with it :

Install-Package JavaScriptEngineSwitcher.ChakraCore.Native.osx-x64 -Version 2.4.6

enter image description here

As per my understanding if i want to use chakracore in my project(console app or web application) then i only need chakra core.dll but still i am getting error that chakra core dll not found.

I have tried in visual studio 2015 and 2017 but same problem.

I have few confusion if someone can answer that :

1) Can chakracore execute any javascript code?

2) Can i pass json result to my javascript and get that json result return from the javascript by executing that javascript code with chakracore?

How run run sample application which should display hello world in console application executing javascript code?

ILoveStackoverflow
  • 1,973
  • 1
  • 11
  • 35
  • Did you put ChakraCore.dll in the output directory? – JLe Jan 08 '18 at 12:14
  • @JLe I have downloaded project from here:https://github.com/Microsoft/Chakra-Samples/tree/master/ChakraCore%20Samples/Hello%20World/Windows/C%23 – ILoveStackoverflow Jan 08 '18 at 12:19
  • @JLe I have even added chakracore.dll from nuget manager but still same error.Can you tell me what do you mean by output directory? – ILoveStackoverflow Jan 08 '18 at 12:19
  • But have you done `Clone and build ChakraCore. You will need to grab ChakraCore.dll from Build\VcBuild\bin\[platform+output]\`? And the Nuget package you used in your post is 1) for .Net Core and 2) for OS X, and neither seem to apply to you. The output directory is where your program is executed, i.e. bin/Debug/. – JLe Jan 08 '18 at 12:20
  • You don't want the OSX assemblies. You don't want the c++ dll either. Did you see the .Net wrapper referred to in the documentation? https://github.com/robpaveza/jsrt-dotnet – Crowcoder Jan 08 '18 at 12:22
  • @JLe Sorry but i tried to find chakracore.dll from Build\VcBuild\bin[platform+output] but unable to find it – ILoveStackoverflow Jan 08 '18 at 12:22
  • @Crowcoder I started reading chakracore docs from today only and trying to implement it but the project which i have downloaded for c# is not working.I am not using c++ dll.I am just failing to understand whats wrong with my project – ILoveStackoverflow Jan 08 '18 at 12:24
  • The first link you provide is for c++. It is hard to tell what exactly you are trying to use at the moment. – Crowcoder Jan 08 '18 at 12:26
  • @Crowcoder Thank you so much for showing interest.This is the project which i am using for c# to execute javascript code using c#(https://github.com/Microsoft/Chakra-Samples/tree/master/ChakraCore%20Samples/Hello%20World/Windows/C%23).My scenario is i want to execute javascript code using c#.So i want to use chakracore to execute any javascript code using its apis – ILoveStackoverflow Jan 08 '18 at 12:28
  • I have a project that uses the Chakra engine in C# somewhere. If I can find it I'll let you know what I'm using. – Crowcoder Jan 08 '18 at 12:34
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/162741/discussion-between-user-and-crowcoder). – ILoveStackoverflow Jan 08 '18 at 12:35

1 Answers1

4

You don't need the Engine Switcher. You only need to reference the official Microsoft.ChakraCore NuGet package from the executable project file.

  • Right-click on the Packages node under the HelloWorld project
  • select Manage NuGet Packages
  • enter 'ChakraCore' into the search box
  • select Microsoft.ChakraCore (it isn't the first item for me)

enter image description here

Once you do, it should run and resolve the ChakraCore.dll included in the NuGet package due to the way the props are done in the package.

Matt Hargett
  • 1,442
  • 1
  • 12
  • 32