Search code examples
signalrsignalr-hub

SignalR - Type or namespace name 'Hub' could not be found


I am new to the SignalR library. I created a new web project in VS2010, then in Package Manager Console I executed the below command to set up the SignalR packages.

PM> Install-Package Microsoft.Aspnet.SignalR -pre

So it downloaded all the necessary files into the application.
----------
Successfully installed 'Microsoft.AspNet.SignalR 1.0.0-rc2'.
Successfully added 'jQuery 1.6.4' to demo.
Successfully added 'Microsoft.AspNet.SignalR.JS 1.0.0-rc2' to demo.
Successfully added 'Newtonsoft.Json 4.5.11' to demo.
Successfully added 'Microsoft.AspNet.SignalR.Core 1.0.0-rc2' to demo.
Successfully added 'Owin 1.0' to demo.
Successfully added 'Microsoft.AspNet.SignalR.Owin 1.0.0-rc2' to demo.
Successfully added 'Microsoft.Web.Infrastructure 1.0.0.0' to demo.
Successfully added 'Microsoft.Owin.Host.SystemWeb 1.0.0-rc2' to demo.
Successfully added 'Microsoft.AspNet.SignalR.SystemWeb 1.0.0-rc2' to demo.
Successfully added 'Microsoft.AspNet.SignalR 1.0.0-rc2' to demo.
----------

Now I added a new class file called LetsHub.cs.

In that file I wrote the following code,

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using Microsoft.AspNet.SignalR.Hubs;

namespace demo.Hubs
{
  [HubName("chatHub")]
  public class LetsChat : Hub
  {
      public void SendMsg(string Message)
      {
         Clients.All.addMessage(Message);
      }
  }
}

I am not able to inherit this Hub class.

Type or Namespace name Hub cound not be found ( are you missing using directive or assemblr reference ? ).

I am facing the same problem on VS 2012 as well.


Solution

  • The Hub class was moved to a different namespace in in RC2. please change to Microsoft.AspNet.SignalR