简体   繁体   English

C#错误? -用户代码未处理System.NullReferenceException

[英]C# Bug? - System.NullReferenceException was unhandled by user code

I keep getting this error even tho the strings that i want to call to a function aren't null 即使我想调用函数的字符串不为空,我仍然会收到此错误

在此处输入图片说明

(As you can see in pic the string isn't null) (如您在图片中看到的,字符串不为空)

This is the error 这是错误

System.NullReferenceException was unhandled by user code 用户代码未处理System.NullReferenceException
Message=Object reference not set to an instance of an object. Message =对象引用未设置为对象的实例。

I even added some code to "handle", I mean to see if the strings are null, and they aren't but still it shows the error 我什至在“句柄”中添加了一些代码,我的意思是看字符串是否为空,虽然不是,但仍然显示错误

if (opp1name != null && opp2name != null && opp3name != null)

This may be useful too? 这可能也有用吗?

在此处输入图片说明

This could also occur if pl is null , or if something required within the pl.Send method (aside from the passed arguments) is null . 如果这也可能发生plnull ,或者如果需要内东西pl.Send方法(除了传递的参数)为null

Make sure to properly instantiate pl (so it is not null), as this is the most likely cause of the issue. 确保正确实例化pl (因此它不为null),因为这很可能是问题的原因。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM