[英]How to fix Xamarin 'System.ArgumentNullException: 'Value cannot be null. Parameter name: address' Exception
When building and running the Application I get a 'System.ArgumentNullException: 'Value cannot be null.在构建和运行应用程序时,我得到一个 'System.ArgumentNullException:'值不能为空。 Parameter name: address' Exception.
参数名称:地址'异常。
The Exception Points to this section of code, to line where the Endpoint is initialized:异常指向这部分代码,指向初始化端点的行:
public void sendInstruction(string instruction)
{
char[] charInput = instruction.ToCharArray();
Byte[] sendBytes = Encoding.ASCII.GetBytes(charInput);
IPEndPoint epWK = new IPEndPoint(ip, port);
udp.Send(sendBytes, sendBytes.Length, epWK);
}
All Parameters are defined before:所有参数都在之前定义:
public IPAddress ip;
public int port;
UdpClient udp = new UdpClient();
And set:并设置:
ip = IPAddress.Parse("192.168.178.62");
port = 54490;
The code worked before so I don't understand why this exception triggers.该代码以前工作过,所以我不明白为什么会触发此异常。
可能在调用 sendInstruction 之前没有调用初始化 ip 的代码。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.