Closed SrinivasGourarum closed 8 years ago
Sure I'm here to help @SrinivasGourarum. Basically we have slightly different bytecode for normal script and script in debug mode so we disable serialization in debug mode (otherwise your serialized bytecode in debug mode would not run normally later). Comment out or delete JsStartDebugging
call and you should be fine.
Since we do not know the size of the buffer to be created, should we first call JsSerializeScript to get the size of the buffer and again calling the same api to load the buffer as in the below code?
ulong buffSize = 0;
byte[] buff = null;
JavaScriptErrorCode errCode = Native.JsSerializeScript(script2Serialize, buff, ref buffSize);
if (errCode == JavaScriptErrorCode.NoError)
{
buff = new byte[buffSize];
errCode = Native.JsSerializeScript(script2Serialize, buff, ref buffSize);
}
Yes your understanding is correct. If you don't have a big enough buffer when you call JsSerializeScript, the function would return the correct buffer size. Since there is no way of knowing how large the buffer needs to be at first, in practice, you usually call JsSerializeScript twice, the first time figuring out the buffer size.
We've done similar thing in our ch.exe host (note it uses ChakraCore not Chakra but it's the same idea).
Thanks Limin.
Did you get a chance to look at https://github.com/Microsoft/Chakra-Samples/issues/16? It has been long pending :(.
Hi Limin,
When trying to serialize a script, I am getting an error code "CannotSerializeDebugScript". The sample is uploaded @ https://onedrive.live.com/redir?resid=9C4512A9CBBBEB98!115&authkey=!AM81bn-hC92WIDQ&ithint=file%2czip .
Could you please help me with this?
Regards, Srinivas.