Unexpected result when calling C# code in Node.js -


so have small node.js webserver uses edge.js connect c# written dll. in our c# code(which class library) calling method performs query neo4j. if test in console app, works fine, when run node.js following exception:

system.aggregateexception: 1 or more errors occurred. ---> system.typeinitiali zationexception: type initializer 'friendlibrary.api.searching' threw exception. ---> system.nullreferenceexception: object reference not set instance of object.    @ friendlibrary.api.searching..cctor()    --- end of inner exception stack trace ---    @ friendlibrary.api.searching..ctor()    @ startup.<<invoke>b__1>d__4.movenext() --- end of stack trace previous location exception thrown ---    @ system.runtime.compilerservices.taskawaiter.throwfornonsuccess(task task)    @ system.runtime.compilerservices.taskawaiter.handlenonsuccessanddebuggernot ification(task task)    @ startup.<<invoke>b__0>d__6.movenext() --- end of stack trace previous location exception thrown ---    @ system.runtime.compilerservices.taskawaiter.throwfornonsuccess(task task)    @ system.runtime.compilerservices.taskawaiter.handlenonsuccessanddebuggernot ification(task task)    @ startup.<invoke>d__9.movenext()    --- end of inner exception stack trace --- ---> (inner exception #0) system.typeinitializationexception: type initializ er 'friendlibrary.api.searching' threw ex ception. ---> system.nullreferenceexception: object reference not set inst ance of object.    @ friendlibrary.api.searching..cctor()    --- end of inner exception stack trace ---    @ friendlibrary.api.searching..ctor()    @ startup.<<invoke>b__1>d__4.movenext() --- end of stack trace previous location exception thrown ---    @ system.runtime.compilerservices.taskawaiter.throwfornonsuccess(task task)    @ system.runtime.compilerservices.taskawaiter.handlenonsuccessanddebuggernot ification(task task)    @ startup.<<invoke>b__0>d__6.movenext() --- end of stack trace previous location exception thrown ---    @ system.runtime.compilerservices.taskawaiter.throwfornonsuccess(task task)    @ system.runtime.compilerservices.taskawaiter.handlenonsuccessanddebuggernot ification(task task)    @ startup.<invoke>d__9.movenext()<--- 

what trying call method in dll return json array node.js pass front end, cannot return json array?

our c# code follows:

    public string getallfriends()     {         string jsonarray = null;          query query = new query();          //this basic cypher query returns ienumerable<person>         var result = query.getallfriends();          list<person> list = new list<person>();          foreach (var node in result )         {             list.add(new person             {                 age= node.data.age,                 name = node.data.name,             });         }         //our result must returned json string         jsonobject = jsonconvert.serializeobject(list);          return jsonobject;     } 

the code above works 100% in our test console application.

now node.js code:

var express = require("express"); var app = express();  var hitthindll = require('edge').func(function(){/*     #r "friendlibrary.dll"     using friendlibrary.api.searching;      async(input)=>{          return await task.run<object>(async () => {             console.writeline("entering c# async function, sleeping 5sec");             contentretrieval ct = new contentretrieval();             string json = ct.getallfriends();             console.writeline("sleep done, returning changes.");             return json;         });      } */});  app.get("/", function(req, res) {       hitthindll(null, function(error, result){         if (error) throw error;         console.log(result);       });     res.end();  });      setinterval(function() {         console.log('node.js event loop alive');     }, 1000);      app.listen(8989); 

could c# function not returning data correctly? async problem?

this might sound stupid had problem time ago well. when testing different versions of our dll occurred .dlls required our deeper tier .dlls weren't in node folder.


Comments

Popular posts from this blog

ios - UICollectionView Self Sizing Cells with Auto Layout -

node.js - ldapjs - write after end error -

DOM Manipulation in Wordpress (and elsewhere) using php -