FIX: radcaptcha throws unhandled NullReferenceException on server side when no default audio playback device exists.
Hello, currently running Telerik.Web.UI.dll v.2010.1.519.35.
A NullReferenceException is being thrown by w3wp.exe that eventually brings down the app pool (if it happens enough times in a short period):
Application: w3wp.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.NullReferenceException
Stack:
at System.Speech.Internal.ObjectTokens.RegistryDataKey..ctor(System.String, System.Speech.Internal.ObjectTokens.RegistryDataKey)
at System.Speech.Internal.ObjectTokens.SAPICategories.DefaultDeviceOut()
at System.Speech.Internal.Synthesis.VoiceSynthesis..ctor(System.WeakReference)
at System.Speech.Synthesis.SpeechSynthesizer.get_VoiceSynthesizer()
at System.Speech.Synthesis.SpeechSynthesizer.SetOutputStream(System.IO.Stream, System.Speech.AudioFormat.SpeechAudioFormatInfo, Boolean, Boolean)
at System.Speech.Synthesis.SpeechSynthesizer.SetOutputToWaveStream(System.IO.Stream)
at Telerik.Web.UI.CaptchaAudio.SpeakText()
at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
at System.Threading.ThreadHelper.ThreadStart()
This error is found in the Application Windows Event log.
I can confirm that the server on which the website using the RadCaptcha control does *not* have a default Playback audio device (or any audio devices at all).
I am able to detect this particularly when trying to access/use a page that contains the audio-enabled RadCaptcha control.
If I change the ASP.NET code within the control definition from...
CaptchaImage-EnableCaptchaAudio="true"
... to ...
CaptchaImage-EnableCaptchaAudio="false"
... the error no longer occurs.
The audio files are in the default location within the directory structure of the web application (App_Data/RadCaptcha).
So, this leads me down two paths:
1) Is it a requirement for the web server to have an enabled default playback device in order for audio play to work on a RadCaptcha control? If so, is this documented?
2) Can this NullReferenceException be handled more elegantly so that it does not crash the worker process altogether?
Given my current version (2010.1.519.35), the behavior might be different in a later version. That would be of interest as well.
Thank you very much!