Author Topic: seemingly random 'System.NullReferenceException' occurred in Unknown Module  (Read 360 times)

chrisw100

  • Posts: 3
Hi

Im using Bass.Net.dll 2.4.14.0, Bass.dll 2.4.14.0 on windows 10 64 bit VB.net 2017, im getting the following error (see screen shot of error and what application was doing at time of stopped execution and source code).
'An unhandled exception of type 'System.NullReferenceException' occurred in Unknown Module. Object reference not set to an instance of an object.'

But as its a break, I've no idea what or where this is being caused. ive added try catch to see if that helps - alas not, and added console text to debug what code has executed. Basically im cycling around 3 streams, and each stream loads and plays the audio which is at the top of a list (datagrid). The streams have a sync end applied on playback and a slide sync callback. it seems random when and what seems to cause this problem to occour, in the screenshots included, execution appeared to stop once stream 2, reelworld_9.mp3 came to and end as I was watching the at the label at the top is displaying 1 0 0 (which is the call Bass.BASS_ChannelIsActive, that's polled via a timer every 50ms) and updates for all 3 streams to show status. sometimes I can have to really hammer the application making it play items lots of times to create the error.

any help or clues would be great,

thank you

Chris.

Ian @ un4seen

  • Administrator
  • Posts: 22253
I'm not sure but perhaps it's a delegate garbage collection issue. What happens if you move these 2 lines to the Form1_Load function? (so that the same delegates are used for all streams)

Code: [Select]
                _mySync = New SYNCPROC(AddressOf EndSync)
                _mySyncSlide = New SYNCPROC(AddressOf EndSyncSlide)

chrisw100

  • Posts: 3
Hello Ian,

Thank you for your prompt reply. Iíve done what you said, and so far, try as I might, I cannot reproduce the fault. I think I understand you reason for putting that code in the form load and not called each time a new play command is issued.

Many thanks again, and thanks for all your work with Bass.

Ian @ un4seen

  • Administrator
  • Posts: 22253
Good to hear that the change fixed the problem. The issue was probably that when you overwrote the _mySync and _mySyncSlide variables, the previous SYNCPROC delegates were no longer referenced and got garbage collected while the syncs were still active, resulting in the exception when BASS tried to call them.