简体   繁体   English

我需要在“使用”中添加什么才能让我的代码运行?

[英]What do I need to add with “using” to get my code to run?

I am looking at some code for using a hub with signalr, C#, and asp.net.我正在查看一些代码,用于使用带有 signalr、C# 和 asp.net 的集线器。 There are red squigglies under:下面有红色的波浪线:

public override Task OnConnected()

public override System.Threading.Tasks.Task OnDisconnected()

return base.OnDisconnected();  

What do I need to include as using to get the code to run?为了使代码运行,我需要包括什么?

These have been added already:这些已经添加:

using System.Linq;  
using System.Web;  
using Microsoft.AspNet.SignalR;

There are red squigglies under the words:字下面有红色的波浪线:

Task OnConnected() and 
OnDisconnected().

If you are trying to overload the OnConnected and OnDisconnected methods of the Hub, you will need to fill in the actual method.如果您尝试重载 Hub 的OnConnectedOnDisconnected方法,则需要填写实际方法。

public override Task OnConnected()
{
   // your code here
   return base.OnConnected();
}

public override Task OnDisconnected()
{
   // your code here
   return base.OnDisconnected();
}

However, it's debatable whether you actually want to do this at all.但是,您是否真的想要这样做是有争议的。 It's more than likely you don't need this code and it can be completely omitted.您很可能不需要此代码,并且可以完全省略它。

If those are all of your using statements then you are probably also missing System.Threading.Tasks .如果这些都是您的 using 语句,那么您可能还缺少System.Threading.Tasks Although with so little information it could be anything.尽管信息如此之少,但它可能是任何东西。 Typically Visual Studio will indicate to you what you need to do to make the red squiggles go away.通常,Visual Studio 会向您指示您需要做什么才能使红色曲线 go 消失。 If not then it may be a missing or broken Nuget package or an inconsistency in framework versions.如果不是,则可能是缺少或损坏的 Nuget package 或框架版本不一致。

Good luck my dude.祝你好运,我的伙计。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM