c# - Cant debug Using QueueClient.OnMessage on a console app -


i need able debug following console application know if messages correctly deserialized or not.

however, when press f5 on visual studio, can debug line:

string mensaje = message.getbody();

but following line seems not executed, , console app closes , can't see message wrote console. best guess because nature of async calls onmessage thing. not sure.

class program     {         static void main(string[] args)         {             try             {                 string connectionstring = cloudconfigurationmanager.getsetting("microsoft.servicebus.connectionstring");                 console.writeline("press key continue");                 console.readkey();                 queuehelper.receivemessageempresa("empresa", connectionstring);             }             catch (exception ex)             {                 throw ex;             }         }     }  public static void receivemessageempresa(string queuname, string connectionstring)         {             queueclient client = queueclient.createfromconnectionstring(connectionstring, "empresa");              // configure callback options             onmessageoptions options = new onmessageoptions();             options.autocomplete = false;             options.autorenewtimeout = timespan.fromminutes(1);              // callback handle received messages             client.onmessage((message) =>             {                 try                 {                     string mensaje = message.getbody<string>();                     empresa empresa = jsonconvert.deserializeobject<empresa>(mensaje);                     // process message queue                     //console.writeline("body: " + );                     console.writeline("messageid: " + message.messageid);                     console.readkey();                      // remove message queue                     message.complete();                 }                 catch (exception ex)                 {                     // indicates problem, unlock message in queue                     message.abandon();                 }             }, options);         } 

or how can rewrite method return object? or suggest?

we've run exact problem afternoon , after taking code out line line found it's using newtonsoft. if comment out line:

empresa empresa = jsonconvert.deserializeobject<empresa>(mensaje); 

you should find works.

we've got round wrapping jsonconvert functionality in class we're calling our onmessage method.

i've no idea why case unfortunately, hope helps!


Comments

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -