失敗擺弄在VS2015所有(?)編譯器和連接選項之後,我發現瞭如何設置我binding.gyp
相反,爲了獲取.NET工作:
{
"targets": [
{
"target_name": "addon",
"sources": [ "hello.cc" ],
"msbuild_settings": {
"ClCompile": {
"CompileAsManaged": "true",
"ExceptionHandling": "Async",
},
},
}
]
}
我的成功執行的託管和非託管代碼如下混合證實構建:
#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();
callManaged();
args.GetReturnValue().Set(String::NewFromUtf8(isolate, "woooooorld"));
}
void init(Local<Object> exports) {
NODE_SET_METHOD(exports, "hello", Method);
}
NODE_MODULE(addon, init)
}