ClearScript apparently can't find a function added dynamically to the window object.
In a regular html file, I can call "var passwordAnalysis = zxcvbn($(this).val(), penalties);" just fine.
However, I am trying to execute https://raw.github.com/lowe/zxcvbn/master/zxcvbn.js inside a C# project.
I always get the exception:
ScriptEngineException: TypeError: Method or property not found.
I suspect it is because the zxcvbn method is added dynamically.
C# Code is as follows:
using Microsoft.ClearScript;
using Microsoft.ClearScript.V8;
public class RunScripts
{
public void GetPasswordStrength(string password, string[] penalties)
{
using (var engine = new V8ScriptEngine())
{
engine.Execute(ZxcvbnScript);
var result = engine.Script.zxcvbn(password, penalties);
//or
var result = engine.Script.zxcvbn(password);
//or
var result = engine.Script.zxcvbn(password);
}
}
}
Comments: I had actually moved to using an ExpandoObject to add the host object, but not adding a host object at all is even better. Thanks for the tip!
In a regular html file, I can call "var passwordAnalysis = zxcvbn($(this).val(), penalties);" just fine.
However, I am trying to execute https://raw.github.com/lowe/zxcvbn/master/zxcvbn.js inside a C# project.
I always get the exception:
ScriptEngineException: TypeError: Method or property not found.
I suspect it is because the zxcvbn method is added dynamically.
C# Code is as follows:
using Microsoft.ClearScript;
using Microsoft.ClearScript.V8;
public class RunScripts
{
public void GetPasswordStrength(string password, string[] penalties)
{
using (var engine = new V8ScriptEngine())
{
engine.Execute(ZxcvbnScript);
var result = engine.Script.zxcvbn(password, penalties);
//or
var result = engine.Script.zxcvbn(password);
//or
var result = engine.Script.zxcvbn(password);
}
}
}
Comments: I had actually moved to using an ExpandoObject to add the host object, but not adding a host object at all is even better. Thanks for the tip!