Skip to content

Microsoft.ClearScript.BindSignature already added? #541

@flat-eric147

Description

@flat-eric147

Hi, I'm running into a funny issue when some recursion from c# to Javascirpt happens.

My v8 script looks like this:

Global.OnParameterChanged = function (id)
{
   somecSharpObject.Value = Date.now() + ""
}

somecSharpObject is a C# object instance added through the AddHostObject method and its Value property looks more or less like this:

private string internalValue;
public string Value
{
    get
    {
        return internalValue;
    }
    set
    {
            if (value != internalValue)
            {
                internalValue = value;
                RaiseParameterEvent(); // this calls Global.OnParameterChanged script callback
            }
        }
    }
}

So as you can see this might lead to some recursions calling the set method which in turn calls the V8 method and so on.

The script engine fires a strange exception after the second time the script method is invoked:

An item with the same key has already been added. Key: Microsoft.ClearScript.BindSignature
at Global.OnParameterChanged (Module:4:27) -> somecSharpObject.Value = Date.now() + ""

I would expect a stack overflow exception in the worst case. I suspect everytime a method is invoked from C# to V8 there are some execution context's that get created adding built in host objects? Tried to build ClearScript from code to have a look but I am stuck in Windows 10 SDK madness.

The error is a little bit confusing. Any ideas on what is going on here? I will try to create a minimal project to reproduce the issue, but wanted to hear first if anybody has an opinion on that :-)

Thank you!

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions