Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7948849
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T01:50:35+00:00 2026-06-04T01:50:35+00:00

nodeJS: io.sockets.on(connection,function(client) { client.emit(‘Value’,{Data:’a string’}); }); C#: socket.On(Value, (data) => { PlainString PS =

  • 0

nodeJS:

io.sockets.on("connection",function(client)
{
  client.emit('Value',{Data:'a string'});
});

C#:

socket.On("Value", (data) =>
{
  PlainString PS = data.Json.GetFirstArgAs<PlainString>();
  MessageBox.Show(PS.Data);
});

C# PlainString Class:

[JsonObject(MemberSerialization.OptIn)]
class PlainString
{
   [JsonProperty]
   public string Data { get; set; }
   public PlainString(){}
   public string ToJsonString()
   {
     return JsonConvert.SerializeObject(this);
   }
   public static PlainString Deserialize(string jsonString)
   {
      return JsonConvert.DeserializeObject<PlainString>(jsonString);
   }
}

error:

Cannot implicitly convert type ‘object’ to ‘PlainString’.
An explicit conversion exists (are you missing a cast?)

on JsonEncodedEventMessage.cs:39

    public T GetFirstArgAs<T>()
        {
            try
            {
                var firstArg = this.Args.FirstOrDefault();
                if (firstArg != null)
                return JsonConvert.DeserializeObject<T>(firstArg.ToString());//line 39
            }
            catch (Exception ex)
            {
                throw;
            }
            return default(T);
        }

firstArg = '{ "Data": "connected" }' (dynamic)
and
T = PlainString

using: SocketIO4Net

everything looks right, but i always get that error, am i missing something?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T01:50:36+00:00Added an answer on June 4, 2026 at 1:50 am

    I don’t know that library but usually Deserializers return object.

    Try this:

    public static PlainString Deserialize(string jsonString)
    {
        return (PlainString)JsonConvert.DeserializeObject<PlainString>(jsonString);
    } 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using Nodejs and Socket.io. When the client connects, new JavaScript objects are created.
I just want to validate some data with nodejs & socket.io server-side. So I
I want to realize a simple client-server connection using Nodejs. But I've encountered with
I'm running a nodejs / socket.io (v 0.7) server to push data to web
I am building a small app that uses backbone.js on the client side, node.js/socket.io
I am using node.js socket.io-client and socket.io . I have a javascript program which
I'm having trouble connecting to socket.io with the client being located on a different
I create a little application with nodejs that stream a multipart/x-mixed-replace data to browser.
I've made a chat client with different chat rooms in NodeJS, socketIO and Express.
I am making my first app with socket.io and nodejs just as socket.io offical

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.