Quantcast
Channel: ClearScript
Viewing all articles
Browse latest Browse all 2297

Edited Issue: Get an exception on engine.Script.print(DateTime.Now.DayOfWeek); [9]

0
0
```
public class StudentInfo
{
public string Name
{ get; set; }

public int Age
{ get; set; }
}

public static void Main()
{


using (var engine = new JScriptEngine("abcaasfgggg", WindowsScriptEngineFlags.EnableDebugging))
//using (var engine = new V8ScriptEngine(typeof(ClearScriptConsole).Name, V8ScriptEngineFlags.EnableDebugging))
{

//engine.AddHostObject("host", new ExtendedHostFunctions());
//engine.AddHostObject("lib", HostItemFlags.GlobalMembers, new HostTypeCollection("mscorlib", "System", "System.Core", "ClearScript"));
engine.AllowReflection = true;
// expose a host type
engine.AddHostType("Console", typeof(Console));
engine.AddHostType("StudentInfo", typeof(StudentInfo));
engine.Execute(@"Console.WriteLine('{0} is an interesting number.', Math.PI);

var studentInfo = new StudentInfo();
studentInfo.Name=""aaa"";
studentInfo.Age = 546;
function print(x) { Console.WriteLine(x); }

");
// call a script function


var kk1 = engine.Script.studentInfo;
engine.Script.print(DateTime.Now.DayOfWeek);
//Get an exception on here. when change engine to V8 that works.


}
}
```

Viewing all articles
Browse latest Browse all 2297

Latest Images

Trending Articles





Latest Images