在High Sierra上使用.NET Core 2.1.4,我有以下代码:
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
但是,当我从终端(使用sudo ./Applications/Visual Studio.app/Contents/MacOS/VisualStudio
)以提升的特权打开Visual Studio for Mac并尝试运行该程序时,出现以下错误:
Error: Unable to connect to the specified connection id.
bash: /tmp/tmp339daafd.tmp: Permission denied
如何从Mac的Visual Studio内部正确运行此程序?
我在使用SUDO为mac启动mac的Visual Studio时有类似的要求->> sudo“ / Applications / Visual Studio.app/Contents/MacOS/VisualStudio”