Tag: edge.js

传递SQL Server连接(节点到C#)

我目前正在使用Node.js服务器。 这个服务器使用Edge.js来执行我的C#工作stream程代码(这是一个dll)。 我们正在使用一个自定义的书面日志loggingDLL日志到SQL Server表。 Node.js和我的工作streamdll使用这个日志dlllogging到SQL数据库的步骤。 理想情况下,只需要打开与SQL数据库的连接一次,然后将其用于Node和Edge / c#代码。 有没有办法在Node.js代码中打开连接,然后将连接句柄传递给Edge / C#。 还是有更好的方法来做到这一点? 目前,我只是打开连接,当我打电话给我的C#工作streamDLL,然后在最后closures它。 在Node中这样做会导致一些问题(假设由于asynchronous代码)“System.InvalidOperationException:ExecuteNonQuery需要一个开放的可用Connection,连接的当前状态是打开的。”

使用节点js中的边来绑定DLL库不成功

我试图学习如何使用边缘(一个node.js模块)绑定预编译的DLL,但它不能以正确的方式工作… 我的DLL是一个非常简单的库,它已经在其他.Net程序中多次testing。 我用Jscript.Net写了我的DLL文件: import System; import System.Console; import System.IO; package power{ public class testp { function hello (){ var time_1 = DateTime.Now; for (var i =0; i<10000; i++){ Console.WriteLine ("hello world!"); }; var time_2 = DateTime.Now; Console.WriteLine (time_2-time_1); }; }; }; 它真的很简单,Hello()方法将在标准输出中打印出10000个“hello world”; 我可以在我的其他Jscript.net程序中调用它: import System; import System.Console; import System.IO; import power; var pri = […]

从C#控制台应用程序中使用Edge.js

我正在尝试做一些看起来很简单的事情,但是我无法让它工作。 我已经通过nuget安装了Edge.js,我想从C#控制台应用程序中执行一段JavaScript。 从我的public static void main代码如下: Task.Run(async () => { Console.WriteLine( await Edge.Func("return function() { return 'hello world'; }")(null).Result ); }).Wait(); 我运行的应用程序,它所做的是挂起。 我试过这个: Console.WriteLine(Edge.Func("return function() { return 'hello'; }")(null).Result); 同样的结果。 这也是… var task = Edge.Func("return function() { return 'hello'; }")(null); await task; Console.WriteLine(task.Result); 同样的结果。 挂… 我也尝试了RunSynchronously()而不是等待,这给了我一个InvalidOperationException 。 我在这里跟着文档。 有任何想法吗?

为什么我的socket.io事件通过大块?

我正在尝试构build一个实时游戏,并通过node.js和sockets.io向客户端进行stream媒体更新。 我正在使用最新的Chrome浏览器,但我也尝试过FF。 所有的服务器端代码都正确地login到控制台,所以我知道在那里的时间是好的,但在客户端,似乎消息是“块”而不是stream。 服务器: var util = require("util"); var io = require("socket.io"); var socket = io.listen(8000); init () { socket.sockets.on("connection", onSocketConnection); }; function onSocketConnection(client) { util.log("New player has connected: " + client.id); client.on("disconnect", onClientDisconnect); client.on("getMatchupUpdates", onUpdateMatchup); }; /* I'm calling an edge.js function to perform game stuff with a callback to a js function 'onUpdateTime' […]

调用Node.js中的C#代码时出现意外的结果

所以我们有一个小型的node.jsnetworking服务器,它使用edge.js连接到一个C#写的DLL。 在我们的C#代码(这只是一个类库),我们正在调用一个方法,执行一个查询到Neo4j。 现在,如果我们在控制台应用程序中testing它,它可以正常工作,但是当我们运行node.js时,我们得到以下exception: System.AggregateException: One or more errors occurred. —> System.TypeInitiali zationException: The type initializer for 'FriendLibrary.API.Searching' threw an exception. —> System.NullReferenceException: Object reference not set to an instance of an object. at FriendLibrary.API.Searching..cctor() — End of inner exception stack trace — at FriendLibrary.API.Searching..ctor() at Startup.<<Invoke>b__1>d__4.MoveNext() — End of stack trace from previous location where […]

在node.js中加载已编译的Dust.js模板

我正在尝试创build一个采用模板名称的函数,并能够将呈现的模板作为string返回。 我正在使用linkedin的粉尘版本。 我预编译模板(使用grunt-dustjs任务)到一个单一的文件,看起来像这样: (function(){dust.register("collections-nav",body_0);function body_0(chk,ctx){return chk.write("\t<div id=\"collection-loop\"><div class=\"section-title lines desktop-12\"><h2>Shop by Collection</h2></div>").section(ctx.getPath(false, ["bigMutha","TopNavigation"]),ctx,{"block":body_1},{}).write("</div>");}function body_1(chk,ctx){return chk.write("<div class=\"collection-index desktop-3 tablet-2 mobile-3 first\" data-alpha=\"").reference(ctx.get(["Title"], false),ctx,"h").write("\"> <div class=\"collection-image\"><a href=\"").reference(ctx.get(["Url"], false),ctx,"h").write("\" title=\"").reference(ctx.get(["Title"], false),ctx,"h").write("\"><img src=\"//cdn.shopify.com/s/files/1/0352/5133/collections/d_cb_20140312_m_handpicked_grande.jpg?v=1394885208\" alt=\"").reference(ctx.get(["Title"], false),ctx,"h").write("\" /></a> </div><div class=\"collection-info\"><a href=\"/collections/mens-designer-clothing\" title=\"Browse our ").reference(ctx.get(["Title"], false),ctx,"h").write(" collection\"><h3>").reference(ctx.get(["Title"], false),ctx,"h").write("</h3><p>16 items</p></a></div></div>");}return body_0;})() (function(){dust.register("index",body_0);var blocks={"body":body_1};function body_0(chk,ctx){ctx=ctx.shiftBlocks(blocks);return chk.partial("layouts/mainfull",ctx,{});}function body_1(chk,ctx){ctx=ctx.shiftBlocks(blocks);return chk.write("<ul>").section(ctx.get(["TopNavigation"], false),ctx,{"block":body_2},{}).write("</ul>").section(ctx.get(["Products"], false),ctx,{"block":body_3},{});}function body_2(chk,ctx){ctx=ctx.shiftBlocks(blocks);return chk.write("<li>").reference(ctx.get(["Title"], false),ctx,"h").write("</li>");}function body_3(chk,ctx){ctx=ctx.shiftBlocks(blocks);return […]

将页面标记为“async = true”,用于Visual Studio MVC项目

我正在使用Edge.js,以便我可以从C#中调用Node.js。 根据链接中的文档,我会做类似于以下内容: [HttpPost] public ActionResult Input(InputModel obj) { validateInput(obj); return View(); } private async void validateInput(object obj) { var func = Edge.Func(@" return function (data, callback){ var username = data.username, email = data.email; callback(null, username); } "); ViewBag.Msg = (string)await func(obj); } 但是,我得到以下运行时错误: Additional information: An asynchronous operation cannot be started at this time. Asynchronous […]

通过Edge.js从多项目Visual Studio解决scheme中的node.js项目调用Web API

我有一个现有的Web API项目,我想在新的React项目中用作后端。 我猜想直接调用服务器上的Web API(使用Edge.js)而不通过HTTP请求会更快。 应该怎么做? 到目前为止,我向已经包含Web API项目的Visual Studio解决scheme添加了一个Node项目,并将这两个项目都设置为启动项目。 但是,如何从Node项目调用Web API控制器?

从ASP.NET MVC项目运行Edge.js

我有一个有趣的时间试图从ASP.NET MVC项目运行Edge.js。 在Edge文档中,基本的控制台应用程序是这样的: public static async Task Start() { var func = Edge.Func(@" return function (data, callback) { callback(null, 'Node.js welcomes ' + data); }"); Console.WriteLine(await func(".NET")); } static void Main(string[] args) { Start().Wait(); } 这在我的机器上没有问题。 下一步是创build一个ASP.NET MVC项目,并尝试从窗体驱动的控制器操作中运行相同的脚本。 ASP.NET MVC项目默认运行在IIS Express上。 这是控制器: public class HomeController : Controller { public ActionResult Index() { return View(); } […]

节点/边缘:替代node.exe.config

Edge.js文档指出,为了让我的应用程序具有.net设置,我需要把它们放在node.exe.config 。 如何:app.config 在Node.js应用程序中运行C#代码时,应用程序configuration文件是node.exe.config,应该位于node.exe文件的旁边。 这会造成冲突,因为我有几个边缘应用程序运行在这个盒子上。 有什么select?