question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

System.NullReferenceException: Object reference not set to an instance of an object.

See original GitHub issue

Getting a null reference exception when trying to initialize the carousel view. I don’t have a lot of info, because I can’t track down the source of the exception, and no amount of try-catches have been able to narrow it down.

I’m trying to use your carousel, because the only other decent option has stopped support, and is giving me too much grief.

My code for initializing the carousel is:

var carousel = new PanCardView.CarouselView()
            {
                ItemTemplate = new DataTemplate(() =>
                {
                    var img = new CachedImage();
                    img.SetBinding(CachedImage.SourceProperty, "ImageUrl");
                    //img.Clicked += Image_Clicked;
                    return new ViewCell() { View = img };
                })
            };
            carousel.SetBinding(PanCardView.CarouselView.ItemsProperty, nameof(CarouselImages));
            carousel.SetBinding(PanCardView.CarouselView.CurrentIndexProperty, nameof(CarouselPosition));

            CarouselViewContainer.Children.Add(carousel);

From what I can tell, the exception gets thrown sometime after the code runs the return new ViewCell() { View = img }; line.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:9 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
Nixon-Josephcommented, Mar 19, 2018

Sorry, it was my weekend, and this is a work project. I ViewCell not being a view makes a lot of sense, I’ll keep that in mind. I guess I was thinking of it as a ListView.

I’ll try the InCourse property today and see if that helps. And I did add a tap event myself, it’s not a huge thing, just thought it would be nice to have built in 😃

The last carousel I used was intercepting all input, I couldn’t even add a tap listener to the element containing the carousel. It just wouldn’t fire. Yours seems great.

0reactions
AndreiMisiukevichcommented, Mar 19, 2018

@Nixon-Joseph Where did you go?(

Read more comments on GitHub >

github_iconTop Results From Across the Web

Object Reference Not Set to an Instance of an Object
This exception is thrown when you try to access a member—for instance, a method or a property—on a variable that currently holds a...
Read more >
c# - What is a NullReferenceException, and how do I fix it?
The message "Object not set to an instance of Object" means you are trying to use an object which has not been initialized....
Read more >
How can I fix the error: System.NullReferenceException
When you have a statement like A.B.C = E.F; , and you receive an NullReferenceException 'Object reference not set to an instance of...
Read more >
Object reference not set to an instance of an object” error?
The “Object reference not set to an instance of an object” is a very famous error in C# that appears when you get...
Read more >
Get to the Bottom of C# Object Reference Not Set to an ...
So, this error description says that an object that is being called to get or set its value has no reference. This means...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found