Completed
Last Updated: 16 Nov 2016 16:41 by Will
Jeff
Created on: 21 Aug 2013 14:50
Category: Captcha
Type: Bug Report
2
FIX: radcaptcha throws unhandled NullReferenceException on server side when no default audio playback device exists
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!
26 comments
Will
Posted on: 16 Nov 2016 16:41
Thanks, Mikhail.  Your solution fixed it for me and I have an old version of sitefinity that we just moved to newer OS 2012.  It seems to be a windows new enhanced feature to have that set now.

thanks,
Will
Mike
Posted on: 21 Jan 2014 15:38
How to fix it:
Step 1: Go to Web Site Application Pool Advanced Settings -> Under Process Model Section make sure that you are using Custom Account width domain\networkid and set Load User Profile = True
Step 2: Add this user as a Local User, remove as a Member Of Users Group and add as a Member Of Administrators Group.
P.S: We are using Sitefinity 6.2.4910.0

Best Regards, Mikhail Ruf
Jon
Posted on: 11 Dec 2013 22:24
I am also experiencing this problem and found a work around.

If I changed my App Pool identity from "ApplicationPoolIdentity" to a local admin account I did not experience the error.

Thanks Jon W
Erik
Posted on: 13 Nov 2013 14:42
Hello All,

I can confirm! 

The reason is, Benjamin, that when you use a social button of SendMail, a dialog is created with a radcaptcha on it! Never thought of that... When I leave out the SendMail social button, no error is thrown. 

So, if you have catched all errors -and- we have a workaround, where done I would say! :-)


Thanks Benjamin
--------------------------------------------------------------------------
<telerik:RadSocialShare ID="RadSocialShare1" runat="server">
    <MainButtons>
        <telerik:RadSocialButton SocialNetType="SendEmail" />
    </MainButtons>
</telerik:RadSocialShare>

BarnyardBen
Posted on: 12 Nov 2013 13:22
Hi Erik

I have isolated the problem. It is the RadSocialShare control, and more specifically, when adding a SendMail button.

I am not entirely sure why it throws the same error, but for now i have just removed that one button.
Erik
Posted on: 07 Nov 2013 13:53
Hi all,

I did add a support ticket, and we still do not know why I recieve the errors like Benjamin descibed. The only way for me is now: set "User Profile" = true on the app pool (Advanced)

I spend many hours and stopped last month after the quick fix user profile. But, in my case also, with no Captcha anywhere, I recieved the server exception. It is espacially weird because of the base dll's used in 2 programs, while 1 gives the error and the other does not. 

In this case it could have something to do with routing (I used page routing in my asp.net application, so not a MVC)

So, Benjamin, Set user profile to true and see if your problem is gone?

@Mihail : Is there a beta of Q3 SP1? I'm willing to try it.

Erik
ADMIN
Misho
Posted on: 07 Nov 2013 12:57
Hello, 

We've recently handled not only the exceptions specified in davelowery's post but all kind of exceptions in general. The fix will be available in the Q3 2013 SP1. If you are experiencing an issue with Q3 2013 version and would like to send you a custom build for the purpose of testing individually on your side before we release an official version I recommend you to use the Telerik supporting system and submit a ticket where you could specify full details on the issue so that  we could be able to review and send our feedback.

@benjamin: If you are experiencing issues with null reference exception on your web server when there is no Captcha on the page I assume the problem is not related to the Telerik components. Please write back with additional details if I'm missing something.
BarnyardBen
Posted on: 07 Nov 2013 09:42
I am having the exact same problem explained with the null reference exception on our web server, crashing the Application Pool. However, my application does not have a RadCaptcha control anywhere, so just disabling the Audio in the control is not an option. Is there somewhere else where I can disable it? When creating the project, I did select the option to copy the .wav files, as I do need Captcha in the project before release, however, I have not implemented the control yet. I tried deleting all the .wav files from the project, but the problem still remains. After restarting the AppPool, I can have a couple (2-10) requests to the app, and then it crashes again. We have 9 pages in total in the app, sometimes it crashes on the request to the first page, other times on the 3rd or 4th.

Is there maybe a way of installing a "dud" audio device on the server? Or maybe a way of disabling Captcha altogether? I am under the impression that the code given by Dave is in the Telerik.Web.UI reference (I am running version 2013.3.1015.45), and cannot see any other place where RadCaptcha is referenced. The only two Telerik references in my project are Telerik.Web.UI and Telerik.Web.UI.Skins.
Jeff
Posted on: 06 Nov 2013 17:51
Hi, Mihail.

Please confirm that Dave Lowery's concern/issue above has been addressed (or does not exist) in the Q3 2013 release and that the issue is indeed resolved.

Are we now catching the NullReferenceException and/or Exceptions in general, and not only the three specified in Dave's code snippet?

Thank you!
ADMIN
Misho
Posted on: 05 Nov 2013 15:49
Hello, the issue has been resolved and the fix will be available for the next official Service Pack scheduled for October 16th.
Dave
Posted on: 22 Oct 2013 00:06
you changed the method SpeakText to the following BUT YOU FORGOT THE NullReferenceException.  Why not catch ALL exceptions, CanSpeak in all cases then should be false


public void SpeakText()
		{
			this.CanSpeak = false;
			try
			{
				SpeechSynthesizer speechSynthesizer = new SpeechSynthesizer();
				speechSynthesizer.SetOutputToWaveStream(this.AudioMemoryStream);
				int length = this.TextToSpeak.Length;
				speechSynthesizer.Rate = -4;
				for (int i = 0; i < length; i++)
				{
					Dictionary<string, string> strs = this.wordsToSpeak;
					char textToSpeak = this.TextToSpeak[i];
					speechSynthesizer.Speak(strs[textToSpeak.ToString().ToUpper(CultureInfo.InvariantCulture)]);
				}
				this.CanSpeak = true;
			}
			catch (SecurityException securityException)
			{
				this.CanSpeak = false;
			}
			catch (ArgumentException argumentException)
			{
				this.CanSpeak = false;
			}
			catch (InvalidOperationException invalidOperationException)
			{
				this.CanSpeak = false;
			}
		}
Dave
Posted on: 21 Oct 2013 21:47
Stack Trace

   at System.Speech.Internal.ObjectTokens.RegistryDataKey..ctor(String fullPath, RegistryDataKey copyKey)
   at System.Speech.Internal.ObjectTokens.SAPICategories.DefaultDeviceOut()
   at System.Speech.Internal.Synthesis.VoiceSynthesis..ctor(WeakReference speechSynthesizer)
   at System.Speech.Synthesis.SpeechSynthesizer.get_VoiceSynthesizer()
   at System.Speech.Synthesis.SpeechSynthesizer.SetOutputStream(Stream stream, SpeechAudioFormatInfo formatInfo, Boolean headerInfo, Boolean closeStreamOnExit)
   at System.Speech.Synthesis.SpeechSynthesizer.SetOutputToWaveStream(Stream audioDestination)
   at Telerik.Web.UI.CaptchaAudio.SpeakText()
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Threading.ThreadHelper.ThreadStart()
Dave
Posted on: 21 Oct 2013 21:45
I have Q3 2013, 2013.3.1015.45 and the problem still exist
Erik
Posted on: 25 Sep 2013 15:18
Thanks Jeff!
Jeff
Posted on: 25 Sep 2013 15:17
Hi, Erik.

For me, it wasn't so much a matter of installing anything, as it was putting the website on multiple servers and discovering the difference between them.  On servers that had a default audio device installed and enabled, the RadCaptcha audio worked fine.  On servers that had no audio devices installed, it failed in the way described above.

So, in theory, you should be able to fix this issue on a server where it is failing by installing an audio device.  Otherwise, you work around it by disabling audio on the RadCaptcha control.

For us (once confirmed by Telerik), it will be a matter of communicating that, if you want audio on the RadCaptcha control, the server must have audio capability ... otherwise, we turn audio off.  This is, of course, until we install the new DLL on our websites.

Hope that helps!
Erik
Posted on: 25 Sep 2013 10:52
Hello Jeff,

I would agree that this would be a great workaround. 

How did you do this? What did you install on your server? (Win 2008 r2 iis7.5)


Thanks in advance!

Erik

Jeff
Posted on: 24 Sep 2013 14:21
Hi, Mihail.

Thank you for the good news and for your attentiveness along the way.  I'm happy to see this has been fixed in a future release.

In the meantime, for websites we already have in production that use this control under an earlier DLL release, would you concur with my thought that we should enforce/notify that "it is a requirement for the web server to have an enabled default playback device in order for audio play to work on a RadCaptcha control"?

Thanks again!
ADMIN
Misho
Posted on: 23 Sep 2013 17:04
The issue is resolved and the fix will be available in the next official release Q3 2013 scheduled for 16th of Oct. You could also test it with the Q3 2013 Beta which is scheduled for 25th of Sept.
Erik
Posted on: 16 Sep 2013 10:27
Thanks for your fast reply Jeff!

I've been at it the whole weekend on and off. I deleted the website, copied the file again (After I deleted the Captcha's from my proj, there were 2, login an register, and did a build) The server had a reboot 2 times. The problem persists. 
Thank god this website is still in test...

I did see an similar problem with a DNN site I host. When disabling the audio in DNN, the problem went away directly...

so, probably somewhere there is still a reference... This stuff is costing me dearly... spending hours on this simple issue...

@Mihail: can you urge e fix for the 717.45 release? Because when I wait till a new version, new bugs may appear (they always do...) and I have to postpone again...

Erik
Jeff
Posted on: 13 Sep 2013 19:36
Hi, Erik.

In my experience, turning off EnableCaptchaAudio should suffice to prevent the exception being generated going forward.  However, you have to recover from the failures that have already occurred.

If it has happened enough times, you may have to manually restart the app pool on which the web site resides and/or do an IISRESET (after, of course disabling captcha audio on the web page(s) in question) ... something on that order.

I would recommend trying that (being clear that I am not a Telerik employee, so it's not "official" advice) and re-posting with the results ... unless you already have.

Hope it helps.
Erik
Posted on: 13 Sep 2013 19:24
Hello Mihail,

I have the same problem on Windows 2008 R2. But it makes no diffenance if I enable the audio, or not. (CaptchaImage-EnableCaptchaAudio) I now even deleted the whole radcaptcha, but the problem persists... Any clue would be greatly appreciated, since this is blocking the client to use the product...

Erik
ADMIN
Misho
Posted on: 10 Sep 2013 15:42
Hello Jeff,

Thank you for the detailed description of your environment and reproduction steps.
This helped me to replicate the issue and I'm confirming it is happening with the latest version as well.
I'm raising its priority so that we will take it into account and fix it as soon as we could.


Best Regards,
Mihail
Jeff
Posted on: 05 Sep 2013 14:15
Hi, Mihail.

Thank you very much for your follow-up effort.

Here are what I believe are key factors that can help you replicate...

1) Telerik.Web.UI.dll v.2010.1.519.35 
(we can try with more recent versions, but doing a like-for-like DLL comparison first seems prudent)

2) ASP.NET code snippet for using the RadCaptcha control:
<telerik:RadCaptcha ID="RadCaptcha1" runat="server" ValidationGroup="entry" CaptchaImage-EnableCaptchaAudio="true"
	EnableRefreshImage="true" CaptchaLinkButtonText="Try A Different Image" ErrorMessage="You entered invalid characters, please try again!">
</telerik:RadCaptcha>

3) OS of server hosting website: Windows Server 2008 R2

4) Going to Control Panel ... Sound ... Playback tab should show "No audio devices are installed" (as opposed to having devices and disabling them)

5) App Pool for website is using .NET 4.0, an Integrated Pipeline, and the default ApplicationPoolIdentity

I think that the key combination is Item 4 and the CaptchaImage-EnableCaptchaAudio="true" attribute.  Item 4 is possible, I believe, because it is a VM that was never configured to have audio capability.

It might also help to have a button on the page that does a server post-back and to click this button a couple of times.  Once this is done, then check the Windows Application Event logs for w3wp.exe exceptions.

I hope this is enough to allow you to replicate the issue.  If not, please let me know, and I will do some further digging to provide more information.

Thank you!
ADMIN
Misho
Posted on: 05 Sep 2013 07:22
Hello Jeff,

Thank you for the additional clarification of the described issue. It looks like a different problem indeed. I've tried to replicate the unwanted behaviour you have experienced according to the description provided disabling the audio controllers but no avail. It would be very helpful if you could provide us with more environment details and reproduction steps so we could be able to reproduce it on our side.

Thank you for your cooperation in advance.
Best Regards,
Mihail
Jeff
Posted on: 04 Sep 2013 14:24
Hi, Mihail.

The issue that you claim is a duplicate of mine is a client-side issue having to do with IE10 ("An audio tag is created by the captcha control under IE10, event if the audio tag with WAVE files is not supported on this version of the browser.").

My claim is that the issue I'm reporting is a server-side issue that can bring down the application pool of the website itself.

While I see the similarity, in that they relate to audio problems in RadCaptcha, I am having a hard time seeing how these two issues are talking about the same problem.

Please review and let me know if I can be of further help in clarifying the issue.

Thank you!
ADMIN
Misho
Posted on: 04 Sep 2013 08:09
The issue is already logged. You could observe its status here: http://feedback.telerik.com/Project/108/Feedback/Details/57219-problem-with-audio-functionality-of-radcaptcha-under-ie10