Skip to content

Can't connect to an event whose handler type is inaccessible #365

@EntenKoeniq-OLD

Description

@EntenKoeniq-OLD

Hello, i'm trying to use ClearScript with my internal class and everything is working fine, but i can't use a public delegate inside this class because i'm getting an error message with something like: "Error: Access to "Microsoft.ClearScript.EventSource<PROJECT.ScriptContext.EmptyEvent>.connect(object)" is not possible due to the protection level.".

I'm not getting an exception using System.EventHandler instead of a custom delegate

C# code:

...
V8ScriptEngine engine = new V8ScriptEngine();

engine.AddHostObject("API", HostItemFlags.PrivateAccess, new ScriptContext());
...

internal class ScriptContext
{
    public delegate void EmptyEvent();

    public event EmptyEvent OnTest;

    internal void OnTestInvoke()
    {
        OnTest?.Invoke();
    }
}

Javascript code:

API.OnTest.connect(function() {

});

Maybe i'm doing something wrong but i can't find a solution for it.

Thanks!

Metadata

Metadata

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions