C
C#โ€ข8mo ago
Murilo Barbosa

NullReference Exception

Hello, I have this application that retrieves data from the TMDB API, but when I click on Details to be redirected to the Details View, it is returning a NullReference Exception at the TMDBMappingService. The exception is thrown when I try to get the iso_3166_1 value at the GetRating method. I checked and the value is indeed null after the app fetches the Movie data. I'm trying to figure out what's happening but so far I haven't been lucky. I appreciate any help. Repo: https://github.com/murilodab/Cinemanage/blob/main/Services/TMDBMappingService.cs The exception is thrown at line 126.
GitHub
Cinemanage/Services/TMDBMappingService.cs at main ยท murilodab/Cinem...
.NET Core MVC app to track and manage movies/shows - murilodab/Cinemanage
6 Replies
Anu6is
Anu6isโ€ข8mo ago
Use your debugger and check what's null. Is it possible that you have a null date in your dates.results collection?
Murilo Barbosa
Murilo Barbosaโ€ข8mo ago
Yes, I did that. The value I want is indeed returning null from the results. But I still don't know why. Everything seems to be correct. Syntactically at least
Anu6is
Anu6isโ€ข8mo ago
well yeah, a nullref isn't a syntax issue. Check how your collection is being populated ...why is a null value being added
Murilo Barbosa
Murilo Barbosaโ€ข8mo ago
"release_dates": { "results": [ { "iso_3166_1": "AD", "release_dates": [ { "certification": "", "descriptors": [], "iso_639_1": "", "note": "", "release_date": "2023-11-01T00:00:00.000Z", "type": 3 } ] } This is from the API
Murilo Barbosa
Murilo Barbosaโ€ข8mo ago
No description
Murilo Barbosa
Murilo Barbosaโ€ข8mo ago
This is right after I request the details So, the problem is probably in between Yeah, I fixed Thank you. I changed QueryOptions to not null, but I also checked the _appSettings, and a typo was preventing the API to return all the correct values. It actually helped. Thanks ๐Ÿ™‚
Want results from more Discord servers?
Add your server
More Posts