signalR How to call server method from .net client
<p>I want to pass arguments from .net client(Xamarin Android) to hub server.
I call server method in serverHub by method "invoke"</p>

<p>HubServer code:</p>

<pre><code>public class ConversationHub : Hub{

public void SendChatMessage(int conversationId, int messageId, string messageText, bool isChat, LinkViewModel link)
// logic in the method
    }
}
</code></pre>

<p>My entity </p>

<pre><code>public class Message: Entity&lt;int&gt;
{
        public string Url { get; set; }
        public string Title { get; set; }
        public string Description { get; set; }
        public string ImgUrl { get; set; }
        public virtual DetailMessage DetailMessage {get; set;}
}
</code></pre>

<p>My object(model) which I want to pass from .Net client to serverHub by calling method "invoke".</p>

<pre><code>public class  LinkViewModel
    {
        public string Url { get; set; }
        public string Title { get; set; }
        public string Description { get; set; }
        public string ImgUrl { get; set; }

        public LinkViewModel(){}
        public LinkViewModel(Message message){
           Url = message.Url;
           Title = message.Title;
           Description  = message.Description;
           ImgUrl = message.ImgUrl;
</code></pre>

<p>}
    }</p>

<p>Client .Net code(Xamarin Android):</p>

<pre><code>var hubConnection = new HubConnection(hubUrl);
 var chatHubProxy = hubConnection.CreateHubProxy("ConversationHub");
 chatHubProxy.Invoke("SendChatMessage", 3, 0, "Hello world!", false, myObj); // I want to call method from HubConversation
</code></pre>

<p>but it -  </p>

<pre><code>chatHubProxy.Invoke("SendChatMessage", 3, 0, "Hello world!", false, myObj);
</code></pre>

<p>doesn't work, because signalR doesn't want to pass complex object. If I remove parameter "myObj" from method on client and server. Method Invoke will be work successfully . 
How to call method "invoke" with object parameter?</p>

<p>Also I use this serverHub method(sendChatmessage) from UI in js:</p>

<pre><code>myHub.conversationHub.server.sendChatMessage(data.conversationId, data.messageId, data.messageText, data.isChat, JSON.parse(link));
</code></pre>

<p>link represents LinkViewModel in UI. Calling method sendChatMessage in JS works without any problem, but with problem from .Net client. How to resolve this.</p>

<p><strong>Updated:</strong></p>

<p>Also I tried to convert myObj to Json(but it doesn't work):</p>

<pre><code>string jsonObject = JsonConvert.SerializeObject(myObj);// serialization myObj
var hubConnection = new HubConnection(hubUrl);
var chatHubProxy = hubConnection.CreateHubProxy("ConversationHub");
     chatHubProxy.Invoke("SendChatMessage", 3, 0, "Hello world!", false, jsonObject); //pass object as json string, but it doesn't work
</code></pre>

<p><strong>Solution:</strong></p>

<p>I resolve this problem. <strong>When I call method "invoke" from .Net client, first parameters should be objects then primitives</strong>, only in this order(for example in my case):</p>

<pre><code>chatHubProxy.Invoke("SendChatMessage", myObj, 3, 0, "Hello world!", false);//firstly objects 
</code></pre>

<p>And after this I changed corresponding order parameters in UI and Hub methods. And all code fine works-)</p>