Text to Speech in ASP.NET - Access is denied... what to do?

Posted by Magnetic_dud on Stack Overflow See other posts from Stack Overflow or by Magnetic_dud
Published on 2009-06-20T19:31:04Z Indexed on 2011/01/17 15:53 UTC
Read the original article Hit count: 430

On my personal website, i would like to make it "pronounce" something

I solved the "concept" problem, as in here, and on my desktop it works smoothly when launched from visual web developer. Creates a file, and then an embedded player in the page will play it. Perfect.

So, I uploaded it on the server... I get this error 500:

Server Error in '/sapi' Application. Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED)) Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.UnauthorizedAccessException: Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))

ASP.NET is not authorized to access the requested resource. Consider granting access rights to the resource to the ASP.NET request identity. ASP.NET has a base process identity (typically {MACHINE}\ASPNET on IIS 5 or Network Service on IIS 6) that is used if the application is not impersonating. If the application is impersonating via , the identity will be the anonymous user (typically IUSR_MACHINENAME) or the authenticated request user.

(...)

Source Error:

See it below

Source File: c:\mypath\sapi\myfile.aspx.cs Line: 21

Stack Trace:

[UnauthorizedAccessException: Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))]
SpeechLib.SpVoiceClass.Speak(String Text, SpeechVoiceSpeakFlags Flags) +0 prova.Button1_Click(Object sender, EventArgs e) in c:\mypath\sapi\prova.aspx.cs:21 System.Web.UI.WebControls.Button.OnClick(EventArgs e) +111
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +110
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13 System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +1565

Version Information: Microsoft .NET Framework Version:2.0.50727.3053; ASP.NET Version:2.0.50727.3053

This is the source

Source Error:

Line 19: myfile.Open(@"C:\mypath\sapi\gen\hi.wav",SpeechStreamFileMode.SSFMCreateForWrite,false);
Line 20: voice.AudioOutputStream = myfile;
Line 21: voice.Speak("Hi",SpeechVoiceSpeakFlags.SVSFDefault);

I get error on line 21, Voice.speak

That probably means that the aspnet worker user has not some right permission

The generation folder has all the right permissions: an empty file is created.

So, i have to give permission of execute to some system dll?

Do you know which dll? It is not bin\Interop.SpeechLib.dll, on this one the aspnet user has full control

Ps: i have full control on the (windows) server (i mean, access by RDC, is not a shared hosting)

© Stack Overflow or respective owner

Related posts about c#

Related posts about ASP.NET