c# - 试图在 Chrome 中查看 DOM。无法找到接收 SuperSocket 错误
问题描述
我有一个 VisualStudio C# WindowFormApplication。我一直在尝试获取 Chrome 标签的 DOM。我之前在这个网站上看到过一篇文章: Accessing the DOM of a Chrome Tab from Visual Studio
https://github.com/kerryjiang/SuperWebSocket/blob/master/Samples/BasicConsole/Program.cs
它详细说明了如何实现这一点。我将它滚动到我的程序中,我得到一个“找不到 SuperSocket”的错误。必须有一个我在这里缺少的参考,但我无法确定它是什么。
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Windows.Automation;
using SuperSocket.SocketBase;
namespace WindowsFormsApplication1
{
public partial class Form1 : System.Windows.Forms.Form
{
//Global Variables
public static class Globals
{
public static bool EditorWorking = false;
public static bool WEPrompts = true;
public static int EditorCheck = 1;
public static String FuncError = "Form_Load";
public static String NeedToUpload = "No";
}
//private System.Windows.Forms.NotifyIcon notifyIcon1;
//private System.Windows.Forms.ContextMenu contextMenu1;
//private System.Windows.Forms.MenuItem menuItem1;
//private System.ComponentModel.IContainer components;
public Form1()
{
//InitializeComponent();
StartSuperWebSocket();
//CreateTrayIcon();
}
private void StartSuperWebSocket()
{
var appServer = new WebSocketServer();
//Setup the appServer
if (!appServer.Setup(2012)) //Setup with listening port
{
Console.WriteLine("Failed to setup!");
Console.ReadKey();
return;
}
appServer.NewMessageReceived += new SessionHandler<WebSocketSession, string>(appServer_NewMessageReceived);
Console.WriteLine();
//Try to start the appServer
if (!appServer.Start())
{
Console.WriteLine("Failed to start!");
Console.ReadKey();
return;
}
}
}
}
解决方案
你是对的,依赖关系似乎搞砸了。
您需要安装以下 nuget 包:
- 超级插座
- 超级套接字.WebSocket
- SuperSocket.Engine
另外请在您的代码中添加以下内容:
using SuperSocket.WebSocket;
告诉库的维护者他的示例没有编译可能是个好主意。
推荐阅读
- java - 如何将 LocalDate 格式化为用户位置的标准格式?
- wso2 - WSO2 IS 5.3.0 - 租户的管理员用户可以被锁定/禁用吗?
- asp.net - IIS 上的随机 500 错误
- reporting-services - 在 SSRS 中的查找中格式化字段
- dynamics-crm - CRM 2013 重新排序站点地图功能区中的实体
- .net-core - dotnet core webapi调用.net webapi2
- hash - 将 CRC32 值理解为除法余数
- docker - 在 macOS 上运行时,如何让 GitLab Runner 停止像 Linux 一样运行?
- json - 如何定义模式任意 JSON 对象?
- python-3.x - pandas 基于分布的系列抽样