Click here to Skip to main content
15,887,214 members
Home / Discussions / C#
   

C#

 
GeneralRe: How to draw small circle in center rectangle c# Pin
Member 1115802716-Oct-14 23:37
Member 1115802716-Oct-14 23:37 
Questionhaw to upload image in c# code? Pin
biruk-bk16-Oct-14 0:03
biruk-bk16-Oct-14 0:03 
QuestionRe: uploading image in c# Pin
Eddy Vluggen16-Oct-14 0:26
professionalEddy Vluggen16-Oct-14 0:26 
Questionabout c# command for oralce Pin
yuscq15-Oct-14 18:26
professionalyuscq15-Oct-14 18:26 
QuestionRe: about c# command for oralce Pin
Eddy Vluggen16-Oct-14 0:27
professionalEddy Vluggen16-Oct-14 0:27 
AnswerRe: about c# command for oralce Pin
Praneet Nadkar16-Oct-14 0:45
Praneet Nadkar16-Oct-14 0:45 
GeneralRe: about c# command for oralce Pin
yuscq16-Oct-14 16:47
professionalyuscq16-Oct-14 16:47 
QuestionEdge.js problem driving me crazy | I can call code through WebApi route but not from node server Pin
Alaric_15-Oct-14 15:52
professionalAlaric_15-Oct-14 15:52 
So I've run into a snag that is driving me insane. I've built two async connectors: one is to a SQL Server database and have exposed it through WebApi (for a .NET sanity check) and through a Task<object> interface exposed for node consumers. The second uses a TaskCompletionSource that wraps an arbitrary list with a Task (for a node sanity check).

When I Debug the Web Api project and nav to my route that is attached to the database, everything does fine. The data from my database is returned to the browser.

When I node my server attached to the mocked async route, everything does fine. My mock is returned to my server and I spool the object to the console.

HOWEVER...when I try to wire node in to consume the attached data connector, when I browse to the open node port, my server crashes with an error "Process is terminated due to StackOverflowException."

The frustration comes from the fact that I'm doing nothing fancy and the connector retrieves data just fine from an api route.


My server:
JavaScript
var edge = require('edge');
var http = require('http');
var port = process.env.PORT || 8088;


var userRepository = {
        getUsers: edge.func({
            assemblyFile:'Edge.Test.dll',
            typeName: 'Edge.Test.DataConnector',
            methodName: 'Invoke'
        })
};

function logError(error, response){
    console.log('[Error]:{' + error+'}');
    response.writeHead(200, { 'Content-Type': 'text/plain'});
    response.write('[Error]:' + error);
    response.end("");
}

http.createServer(function(request,response){
    console.log('Creating Server...');
    response.writeHead(200, {'Content-Type':'text/html'});
    var payload = {};
    console.log('[Before][userRepository.getUsers]');
    userRepository.getUsers(payload, function(error, result){
        console.log('[Result][userRepository.getUsers]');
        if(error){logError(error, result);return;}
        if(result){
            response.write("<ul>");
            result.forEach(function(user){
                console.log("[Response contains User]{"+user.FirstName+"|"+user.LastName+"}");
                response.write("<li>" + user.FirstName + " " + user.LastName);
            });

            response.end("</ul>");
        }
        else{
            response.end("No users found");
        }
    });
}).listen(port);

console.log("Node server listening on port: " + port);




The async connection point
C#
public async Task<object> Invoke(object input)
        {
            var payload = (IDictionary<string, object>)input;
            return await GetUsers();
        }
        public async Task<List<Data.User>> GetUsers()
        {
            TaskCompletionSource<List<Data.User>> source = new TaskCompletionSource<List<Data.User>>();
            Task<List<Data.User>> task = source.Task;

            var connector = new Data.SqlServer();

            Task.Factory.StartNew(() =>
                {
                    source.SetResult(connector.GetUsersSync());
                });

            return await task;

        }


The ADO.NET calls
C#
public async Task<List<User>> GetUsers()
        {
            List<User> users = new List<User>();
            using (var connection = new SqlConnection(ConnectionString))
            {
                using (Command = connection.CreateCommand())
                {
                    await connection.OpenAsync();
                    Command.CommandType = System.Data.CommandType.Text;
                    Command.CommandText = "SELECT UserId, FirstName, LastName FROM [dbo].[User]";
                    using (Reader = await Command.ExecuteReaderAsync())
                    {
                        while (await Reader.ReadAsync())
                        {
                            User user = new User();
                            user.Id = Reader[0] as int? ?? default(int?);
                            user.FirstName = Reader[1] as string;
                            user.LastName = Reader[2] as string;

                            users.Add(user);
                        }
                    }
                }
            }
            return users;
        }

Again, the TaskCompletionSource returns to node when I put a hard coded List in it. SQL Server returns to the WebApi Controller, but SQL Server will not return to node; I get a Stack Overflow.
"I need build Skynet. Plz send code"


modified 15-Oct-14 23:35pm.

AnswerRe: Edge.js problem driving me crazy | I can call code through WebApi route but not from node server Pin
Alaric_16-Oct-14 6:42
professionalAlaric_16-Oct-14 6:42 
GeneralRe: Edge.js problem driving me crazy | I can call code through WebApi route but not from node server Pin
Alaric_16-Oct-14 7:21
professionalAlaric_16-Oct-14 7:21 
AnswerRe: Edge.js problem driving me crazy | I can call code through WebApi route but not from node server Pin
Alaric_16-Oct-14 9:24
professionalAlaric_16-Oct-14 9:24 
Questionunable to register the dll/ocx regsvr32 failed with exit code 0x4 Pin
Member 245846714-Oct-14 23:40
Member 245846714-Oct-14 23:40 
AnswerRe: unable to register the dll/ocx regsvr32 failed with exit code 0x4 Pin
Pete O'Hanlon14-Oct-14 23:49
mvePete O'Hanlon14-Oct-14 23:49 
AnswerRe: unable to register the dll/ocx regsvr32 failed with exit code 0x4 Pin
Dave Kreskowiak15-Oct-14 2:18
mveDave Kreskowiak15-Oct-14 2:18 
GeneralRe: unable to register the dll/ocx regsvr32 failed with exit code 0x4 Pin
Member 245846715-Oct-14 16:10
Member 245846715-Oct-14 16:10 
GeneralRe: unable to register the dll/ocx regsvr32 failed with exit code 0x4 Pin
Dave Kreskowiak15-Oct-14 17:23
mveDave Kreskowiak15-Oct-14 17:23 
AnswerRe: unable to register the dll/ocx regsvr32 failed with exit code 0x4 Pin
Gerry Schmitz15-Oct-14 10:07
mveGerry Schmitz15-Oct-14 10:07 
GeneralRe: unable to register the dll/ocx regsvr32 failed with exit code 0x4 Pin
Dave Kreskowiak15-Oct-14 11:09
mveDave Kreskowiak15-Oct-14 11:09 
Questionexcel listview c# Pin
Kalay1614-Oct-14 23:33
Kalay1614-Oct-14 23:33 
SuggestionRe: excel listview c# Pin
Eddy Vluggen15-Oct-14 9:00
professionalEddy Vluggen15-Oct-14 9:00 
GeneralRe: excel listview c# Pin
Kalay1619-Oct-14 20:36
Kalay1619-Oct-14 20:36 
GeneralRe: excel listview c# Pin
Eddy Vluggen20-Oct-14 1:57
professionalEddy Vluggen20-Oct-14 1:57 
GeneralRe: excel listview c# Pin
Kalay1620-Oct-14 2:54
Kalay1620-Oct-14 2:54 
GeneralRe: excel listview c# Pin
Eddy Vluggen20-Oct-14 5:27
professionalEddy Vluggen20-Oct-14 5:27 
GeneralRe: excel listview c# Pin
Kalay1620-Oct-14 20:50
Kalay1620-Oct-14 20:50 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.