Eugene Beresovsky Eugene Beresovsky - 5 months ago 32
Node.js Question

How to use mixed C++ & .Net dll in node.js? (Error: abort() has been called)

I want to create a native node extension using a dll containing C++ and C# code in Visual Studio 2015. I cannot make it work following my own instructions of yesteryear, which is based on the latest


When not using the
option, I can run a program like the following just fine.

const addon = require('./build/Release/addon');

When enabling
, only the first call to log gets executed. When compiling the dll in debug mode, I get the following message:

enter image description here

How to fix / debug this?

(I know there's edge, but I am trying to go the node-gyp way)


After unsuccessfully twiddling all (?) the compiler and linker options in VS2015, I found out how to set up my binding.gyp instead, in order to get .Net to work:

  "targets": [
      "target_name": "addon",
      "sources": [ "" ],
      "msbuild_settings": {
        "ClCompile": {
          "CompileAsManaged": "true",
          "ExceptionHandling": "Async",

I verified the build by successfully executing the following mix of managed and unmanaged code:

#include <node.h>
#include <v8.h>

namespace demo {

  #pragma managed

  void callManaged()
    System::String^ result = gcnew System::String("hola");
    System::Console::WriteLine("It works: " + result);

  #pragma unmanaged

  using v8::FunctionCallbackInfo;
  using v8::Isolate;
  using v8::Local;
  using v8::Object;
  using v8::String;
  using v8::Value;

  void Method(const FunctionCallbackInfo<Value>& args) {
    Isolate* isolate = args.GetIsolate();
    args.GetReturnValue().Set(String::NewFromUtf8(isolate, "woooooorld"));

  void init(Local<Object> exports) {
    NODE_SET_METHOD(exports, "hello", Method);

  NODE_MODULE(addon, init)