500 Error (0x80070005 (E_ACCESSDENIED)) in ASP.Net Core API with referenced project

Ori Goldstein 21 Reputation points
2022-02-17T19:20:29.783+00:00

I have created a WebAPI project in .Net Core (3.1) that references / has a dependency to a second project in my solution.

It works perfectly on my local machine, but I published it to my web-host, and I am getting 500 errors from a specific POST method that is using the referenced project.

When I examine the output log, the error looks as follows:

Connection id "0HMFHNV7NFO0R", Request id "0HMFHNV7NFO0R:00000010": An unhandled exception was thrown by the application.
System.UnauthorizedAccessException: Access is denied. (0x80070005 (E_ACCESSDENIED))
at System.Speech.Internal.SapiInterop.ISpRecognizer.SetRecognizer(ISpObjectToken pRecognizer)
...
at <Referenced project & method> in
C:\Users\<username>\...\...\....cs:line 23

Basically, from what I'm seeing, it seems my API is actually trying to access the referenced project at it's original location on my local machine (C:\Users\<username>..........cs:line 23).

I truly don't understand what's happening here since the rest of the API seems to work well except for the parts referencing the other project, but that doesn't make sense to me since .Net core should just supply the relevant DLLs, no?

As a second part to this question as well, the second (referenced project) is using System.Speech which is available in .Net Core 3.1, but I am being told from my hosting provider:

System.Speech requires LocalSystem of Application Pool Identity if you use it in a .net web application. I don't have a better solution, perhaps you can try another Speech library which can work individually for your project.

Is this logical or, since it is a .Net Core package, is it fully self-contained and doesn't need that?

And, more importantly, is there any way to fix to be able to keep using this library?

What can I do to fix this / what does this error mean?

ASP.NET Core
ASP.NET Core
A set of technologies in the .NET Framework for building web applications and XML web services.
4,502 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Bruce (SqlWork.com) 63,741 Reputation points
    2022-02-17T22:02:12.327+00:00

    when you ship the .pdb files, the error message reference to the build source, thus you local machine. You issue is you code is running on the server. The System.Speech uses a windows desktop software that may not be installed on the web server. Desktop software is not typically designed to run from a service. The library is expected to be hosted by a windows app, because it has UI compoenent.

    when you say it run on you local box, was that thru visual studio and IIS Express (which is running with your account under a profile and window) or did you use IIS. Try to get to run with IIS. They are probably correct that it needs a local system. The access denied is probably access to the speech hardwire drivers,

    note: azure or aws have callable speech to text engines. these are probably a better choice. but you might find an AI speech engine you could use.

    1 person found this answer helpful.

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.