我是 SignalR 库的新手。我在 VS2010 中创建了一个新的 Web 项目,然后在包管理器控制台中执行以下命令来设置 SignalR 包。
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.
----------
现在我添加了一个名为LetsHub.cs
.
在该文件中,我编写了以下代码,
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);
}
}
}
我无法继承这个Hub
类。
Type or Namespace name Hub cound not be found ( are you missing using directive or assemblr reference ? ).
我在 VS 2012 上也面临同样的问题。