I have a C# class which contains plenty of methods. I have to access those 
methods from within Node.js, with the help of edge.js. The problem is all 
previous C# methods are synchronous, while calling from Node.js it says 
call as asynchronous.

So I wrote a wrapper class, and tried to call asynchronously, but I 
received this error:

ERROR: "Unable to access the CLR method to wrap through reflection. Make 
sure it is a public instance method"

------------------------------

public class Test{
    string XyzId;
    string XyzRole;

    public Test(string xyzId, string xyzRole)
    {
        XyzId = xyzId;
        XyzRole = xyzRole;
    }
    private static Dictionary<int, Person> _people = new Dictionary<int, 
Person>();

    // My asynchronous Method wrapper over synchronous Method
    public async Task<object> ExecuteLogWarning(dynamic input)
    {
        Test tst = new Test("POC", "POC");
        var task = Task.Run(() => LogWarningTest((string)input.errorCode, 
(string)input.message));
        return task;
    }
    //synchronous method 
    public void LogWarningTest(string errorCode, string message)
    {
        _people.Add(Convert.ToInt32(errorCode), new Person(1, errorCode, 
message));
    }}
public class Person{
    public string FirstName;
    public string LastName;
    public int ID;

    public Person(int id, string firstName, string lastName)
    {
        ID = id;
        FirstName = firstName;
        LastName = lastName;
    }}

------------------------------

Node.js Code

 var edge = require('edge');

 var ExecuteLogWarning = edge.func({
    assemblyFile:'Test.dll',   
    typeName:'Logging.Test',            
    methodName:'ExecuteLogWarning'});   
var joe = ExecuteLogWarning({
errorCode:"1",
message:"Message Runtime"    }, true);

var getPerson = edge.func({
    assemblyFile:'Test.dll',
    typeName:'Logging.Test',
    methodName:'GetPerson'});

console.log(getPerson(1, true));


On Thursday, 18 February 2016 11:08:25 UTC+5:30, Sudhir Goswami wrote:
>
> Hi Geeks,
>
> I have library which contains some methods and property written in C# 
> Language ,I want to access those methods from Node.js?
>
> Below code is my C# Library code.
>
> class Employee{
>     public int Id { get; set; }
>
>     public string EmpName { get; set; }
>
>     public DateTime EmpDob { get; set; }
>
>     public Employee getEmpDetails()
>     {
>         Employee objEmployee = new Employee();
>
>         objEmployee.Id = 11203256;
>
>         objEmployee.EmpName = "John Miller";
>
>         objEmployee.EmpDob = System.DateTime.Now;
>
>         return objEmployee;
>     }        }
>
> So above code produced Employee.dll , Now I want use my getEmpDetails() 
> from node js.
>

-- 
Job board: http://jobs.nodejs.org/
New group rules: 
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
--- 
You received this message because you are subscribed to the Google Groups 
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/nodejs/440d90db-8730-496a-a83f-ca245064acc4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to