Skip to content

Calling AddHostObject throwing Invalid host item #90

Description

@JohnLudlow

A colleague reported that a C++/CLI sample app (which was previously working) using ClearScript was failing when calling AddHostObject with an InvalidOperationException "Invalid host item".

I've been able to reproduce the error on my computer, with

  • the same C++/CLI project
  • a new C++/CLI project
  • a new C# project

I've also reproduced in 5.5.3 (which is what we use) and 5.5.4 (in a new project using the Nuget package) and with .NET 4.6.1 and 4.7.2.

image

Here's the code for my new C# project:

static void Main(string[] args)
{
      using (var engine = new V8ScriptEngine())
      {
           engine.AddHostObject("message", "hello world");
      }
}

Given how it was working and suddenly seems to not be working it may be an environmental thing like Windows Updates but I'd appreciate some pointers.

I was trying to attach a sample but Github was unhappy with the size. When I get chance (might be Monday) I'll attach a Dropbox link or something.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions