简体   繁体   English

如何修复 Xamarin 'System.ArgumentNullException:'值不能为空。 参数名称:地址'异常

[英]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.

相关问题 如何修复“ System.ArgumentNullException:'值不能为null。 参数名称:entity'” - How to fix “System.ArgumentNullException: 'Value cannot be null. Parameter name: entity'” 如何修复 OrganizationServiceProxy“System.ArgumentNullException:值不能为空。参数名称:identityProvider”问题 - How to fix OrganizationServiceProxy "System.ArgumentNullException: Value cannot be null. Parameter name: identityProvider" issue System.ArgumentNullException:'值不能为null。 参数名称:键 - System.ArgumentNullException: 'Value cannot be null. Parameter name: key' System.ArgumentNullException: '值不能为空。 参数名称:items' - System.ArgumentNullException: 'Value cannot be null. Parameter name: items' System.ArgumentNullException: '值不能是 null。 参数名称:providerInvariantName' - System.ArgumentNullException: 'Value cannot be null. Parameter name: providerInvariantName' System.ArgumentNullException: '值不能为空。 参数名称:提供者' - System.ArgumentNullException: 'Value cannot be null. Parameter name: provider' System.ArgumentNullException:“值不能是 null。 参数名称:实体” - System.ArgumentNullException: “Value cannot be null. Parameter name: entity” Telerik Open Access错误:异常:System.ArgumentNullException:值不能为null。 参数名称:converterName - Telerik Open Access error: Exception: System.ArgumentNullException: Value cannot be null. Parameter name: converterName Add-Migration异常:System.ArgumentNullException:值不能为null。 参数名称:属性 - Add-Migration exception: System.ArgumentNullException: Value cannot be null. Parameter name: property System.ArgumentNullException:值不能为 null。(参数“connectionString”) - System.ArgumentNullException: Value cannot be null. (Parameter 'connectionString')
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM