在High Sierra上使用.NET Core 2.1.4,我有以下代码:
false
从终端,我执行:using System;
using System.Net.Sockets;
namespace socketTest
{
class Program
{
static void Main()
{
var udpSock = new Socket(AddressFamily.InterNetwork, SocketType.Raw, ProtocolType.Udp);
Console.WriteLine($"udpSock object is: {udpSock}");
var tcpSock = new Socket(AddressFamily.InterNetwork, SocketType.Raw, ProtocolType.Tcp);
Console.WriteLine($"tcpSock object is: {tcpSock}");
Console.WriteLine("Press any key to exit");
Console.ReadLine();
}
}
}
,输出:
sudo dotnet socketTest
但是,当我使用终端的提升权限(使用udpSock object is: System.Net.Sockets.Socket
tcpSock object is: System.Net.Sockets.Socket
Press any key to exit
)打开Visual Studio for Mac,并尝试运行该程序时,我收到以下错误:
sudo ./Applications/Visual Studio.app/Contents/MacOS/VisualStudio
如何从Visual Studio for Mac内部正确运行它?