我目前正在使用websockets开发一些桌面应用程序(更准确地说:我正在使用Alchemy WebSockets).到现在为止,我的代码工作正常,但Visual Studio 2010告诉我
Warning 2 CA2000 : Microsoft.Reliability : In method 'ServerController.SetupServer(int)', call System.IDisposable.Dispose on object '<>g__initLocal0' before all references to it are out of scope. C:\Users\MaRiedl\documents\visual studio 2010\Projects\Alchemy-WebSockets\AWS-Server\ServerController.cs 38 AWS-Server
Run Code Online (Sandbox Code Playgroud)
我已经尝试用MSDN帮助(http://msdn.microsoft.com/en-us/library/ms182289.aspx)和(当然)通过日夜搜索stackoverflow.com 来解决这个问题(使用"使用"在C#) - 但遗憾的是它不会变得更好.
所以这是我的问题:我是否能够"找到"找不到的问题,或者这只是Visual Studio 2010中的误报?
这是我正在努力解决的一段代码:
private WebSocketServer _webSocketServer;
private void SetupServer(int port)
{
// set port and configure authorized ip addresses to connect to the server
_webSocketServer = new WebSocketServer(port, IPAddress.Any)
{
OnReceive = OnReceive,
OnSend = OnSend,
OnConnect = OnConnect, …Run Code Online (Sandbox Code Playgroud)