panopticoncentral/chakra-host — pull request #3 by billti (2014-10-17 07:25:28+00:00)
Title: Made all DllImports from jscript9 explicitly Unicode

I hit the same issue the user at http://stackoverflow.com/questions/20374455/a-failing-minimal-example-of-executing-js-in-win-8-1-chakra-with-c-sharp/26419517#26419517 hit a while back.

From browsing jsrt.h, looks like all the jscript9.dll APIs use wchar_t whenever a string value is passed, however the CharSet field isn't specified on the DllImport attributes - thus it uses the default of CharSet.Ansi. This was causing ScriptCompile errors when passing in a script as a string value.

I did a simple find/replace to add the CharSet.Unicode value on all the DllImport attributes, and the code is working fine for me now.