1

ClearScript を使用して JavaScript をコンパイルし、それをシリアライズして SQL に保存したいと考えています。しかし、Serializable ではないとマークされています。どうすればよいですか?

V8ScriptEngine engine = new V8ScriptEngine();
V8Script compiled = engine.Compile("var a = 'test'");
using (MemoryStream ms = new MemoryStream())
{
    new BinaryFormatter().Serialize(ms, compiled);
    string compiledString = Convert.ToBase64String(ms.ToArray());
}

次のエラーが表示されます。

Additional information: Type 'Microsoft.ClearScript.V8.V8ScriptImpl' in Assembly 'ClearScriptV8-32, Version=5.4.6.0, Culture=neutral, PublicKeyToken=935d0c957da47c73' is not marked as serializable.
4

1 に答える 1