3

I was previously using an older ver of the signalR.js and everything is fine except it is intermittently causing my page to hang therefore I want to test it out with a newer ver from downloaded from the SignalR github site.

I tried following the client side example of SignalR but I get this error when inspecting element in chrome,

Uncaught TypeError: Object # has no method 'sending'. Anyone came across this error?

  <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"> </script> 
  <script src="/Scripts/jquery.signalR.js" type="text/javascript"> </script>    
  <script src="signalr/hubs" type="text/javascript"> </script>

        var hub = $.connection.testHub;
        hub.showMessage = function() {
                    $("#inboxcount").show();
                };

        $.connection.hub.start()
            .done(function() {
                hub.subscribe($('#<%= hdnUserId.ClientID %>').val());
            })
            .fail(function() {
                alert("Could not Connect!");
            });

TestHub.cs:

using System.Threading;

{
    /// <summary>
    /// Test Hub used to demonstrate the key concepts of SignalR
    /// </summary>
    [SignalR.Hubs.HubName("testHub")]
    public class TestHub : SignalR.Hubs.Hub
    {
        /// <summary>
        /// Broadcast the message to all clients
        /// </summary>
        /// <param name="message">message to be broadcasted</param>
        public void Broadcast(string message)
        {
            this.Clients.showMessage(message);
        }

        /// <summary>
        /// Return a string with the formate, Hello [current user name]
        /// </summary>
        /// <returns></returns>
        public string SayHello()
        {
            //Context property can be used to retreive HTTP attributes like User
            return "Hello " + Context.User.Identity.Name;
        }

        /// <summary>
        /// Simulates a long running process that updates its progress
        /// </summary>
        public void LongRunningMethod()
        {
            Thread.Sleep(1000);
            this.Caller.showMessage("25% Completed");
            Thread.Sleep(1000);
            this.Caller.showMessage("50% Completed");
            Thread.Sleep(1000);
            this.Caller.showMessage("75% Completed");
            Thread.Sleep(1000);
            this.Caller.showMessage("Done");
        }

        /// <summary>
        /// Subscribe to a given message category
        /// </summary>
        /// <param name="category">the category to subscribe</param>
        public void Subscribe(string category)
        {
            //Add current connection to a connection group with the name 'category'
            this.AddToGroup(category);
        }

        /// <summary>
        /// Publish a message to the given mmessage category
        /// </summary>
        /// <param name="category">the category to send the message</param>
        /// <param name="message">the message to be sent</param>
        public void Publish(string category, string message)
        {
            //Broadcast the message to all connections registered under the group 'category'
            this.Clients[category].showMessage(message);
        }
    }

LINQ NotSupportedOperation exception with Code First

I have a DbSet of Contacts and i am trying to execute the following query:

from contact in Context.Contacts 
where contact.Equals("given contact") 
select contact; 

I get a NotSupportedOperationException that the system can't create non-scalar types like integers or string or GUIDs.
How can i execute the same query efficiently without retrieving all records from the database (eg. execute the filtering operation on the SQL server database) ?

NOTE: I have overridden the Equals method in the Contact type.

4

2 に答える 2

0

おそらく使用する必要があります

 <script src="@Url.Content("~/signalr/hubs")" type="text/javascript"> </script>

それ以外の

 <script src="signalr/hubs" type="text/javascript"> </script>

それでも問題が解決しない場合は、プロジェクトに古い SignalR ライブラリがないかどうかを確認する必要があります。したがって、すべての SignalR dll を削除して、以下を追加します。

  • Microsoft.AspNet.SignalR.Core
  • Microsoft.AspNet.SignalR.Hosting.AspNet
  • Microsoft.AspNet.SignalR.Hosting.Common

それは私のためにトリックをしました:)

于 2012-12-21T15:07:26.550 に答える