为什么我的对象有值时仍为null?

时间:2019-05-13 20:55:44

标签: xamarin visual-studio-2017 nullreferenceexception

我尝试显示数字投票 在我的itemDetails页面中,我从页面项目中接收数据,但是当我单击按钮访问项目详细信息页面时,我的所有数据都是可读的(字符串Titre,字符串Description,int投票),当错误消息为null时,试图读取INT。我尝试使用try.parse或转换的多种解决方案,但找不到很好的文字

Image

谢谢

var subscriber = new AutoSubscriber(bus, "example");
subscriber.Subscribe(Assembly.GetExecutingAssembly());

System.MissingMethodException: No parameterless constructor defined for this object.
   at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean wrapExceptions, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor)
   at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean wrapExceptions, Boolean skipCheckThis, Boolean fillCache)
   at System.Activator.CreateInstance[T]()
   at EasyNetQ.AutoSubscribe.DefaultAutoSubscriberMessageDispatcher.DispatchAsync[TMessage,TAsyncConsumer](TMessage message)
   at EasyNetQ.Consumer.HandlerRunner.InvokeUserMessageHandlerInternalAsync(ConsumerExecutionContext context)

1 个答案:

答案 0 :(得分:1)

<Label HorizontalOptions="Center"
                  FlexLayout.Grow="1"
                   x:Name=" MyVote" d:Name="Name!"
                   BackgroundColor="Gray"/>

也许删除MyVote前面的空间可能会解决此问题。

<Label HorizontalOptions="Center"
                  FlexLayout.Grow="1"
                   x:Name="MyVote" d:Name="Name!"
                   BackgroundColor="Gray"/>