如何在NodeJS中调用SS生成的DLL2014-06-10 cnblogs Ivan Zou要想在NodeJS中调用SS生成的DLL, 需要借助EdgeJS.EdgeJS: http://tjanczuk.github.io/edge/如果你还不知道如何在SS 中生成DLL, 请查看: Spider Studio 新版本 (x-mas) - 可以引入第三方程序集, 可以将脚本生成为DLL下面以曾经写过的XML/JSON互转的脚本为例 (C#中 另辟蹊径解决JSON / XML互转的问题) 说明如何在NodeJS中应用SS DLL:1. 安装edgejsnpm install edge2. 为 www.utilities_online.info.XmlJsonConverter.dll编写一个javascript的代理 脚本一共两个方法, Xml2Json & Json2Xml:
var edge = require("edge");exports.xml2json = edge.func({source: function() {/*using System.Threading;using System.Threading.Tasks;using www.utilities_online.info;public class Startup{public async Task<object> Invoke(object input){object result = null;Thread t = new Thread(new ParameterizedThreadStart((p) => { using(var proxy = new XmlJsonConverter()){proxy.Init();result = proxy.Xml2Json(p.ToString());}} ));t.SetApartmentState(ApartmentState.STA);t.IsBackground = true;t.Start(input);while (t.ThreadState != ThreadState.Stopped){Thread.Sleep(100);}return result;}}*/},references: [ __dirname + "\www.utilities_online.info.XmlJsonConverter.dll" ]});exports.json2xml = edge.func({source: function() {/*using System.Threading;using System.Threading.Tasks;using www.utilities_online.info;public class Startup{public async Task<object> Invoke(object input){object result = null;Thread t = new Thread(new ParameterizedThreadStart((p) => { using(var proxy = new XmlJsonConverter()){proxy.Init();result = proxy.Json2Xml(p.ToString());}} ));t.SetApartmentState(ApartmentState.STA);t.IsBackground = true;t.Start(input);while (t.ThreadState != ThreadState.Stopped){Thread.Sleep(100);}return result;}}*/},references: [ __dirname + "\www.utilities_online.info.XmlJsonConverter.dll" ]});