Alxandr / SpotiFire

A project to make a SpotifyClient in C#
http://nudoc.azurewebsites.net/SpotiFire
40 stars 19 forks source link

KeyNotFoundException in Track.Delete when using SpotifyLib as references project #2

Closed ChrisBrandhorst closed 13 years ago

ChrisBrandhorst commented 13 years ago

Error:

Steps to reproduce:

Somehow the error does not occur when I reference the .dll instead of the project.

Fix:

Alxandr commented 13 years ago

I don't really see how the collection could miss the track-pointer unless it was mutated somewhere, are you able to debug it to see if the track-pointer is actually added to the dict?

ChrisBrandhorst commented 13 years ago

Fixed in my branch (see pull request).

The Track that was disposed was not a Track, but a PlaylistTrack. Since PlaylistTrackWrapper did not have its own OnDispose method, the TrackWrapper.OnDisposed was used, resulting in a call to Track.Delete (which of course failed, since PlaylistTracks are stored in a seperate Dictionary).

For this to work, I needed to add public get properties Position and Playlist to PlaylistTrack.