I wrote the code for: searching a word in a document that works without problems in the Console Application, but does not work in ASP.NET Application when I click the button:
using Microsoft.Office.Interop.Word;
Application objWordApp = new Application();
objWordApp.Visible = false;
object missing = System.Reflection.Missing.Value;
Document objDoc;
objDoc = objWordApp.Documents.Open(fileURL, ref missing, ref missing, ref missing,
ref missing, ref missing, ref missing, ref missing,
ref missing, ref missing, ref missing, ref missing, ref missing, ref missing,
ref missing, ref missing);
object findText = "Tags";
objDoc.Content.Find.ClearFormatting();
try
{
if (objDoc.Content.Find.Execute(ref findText,
ref missing, ref missing, ref missing, ref missing, ref missing, ref missing,
ref missing, ref missing, ref missing, ref missing, ref missing, ref missing,
ref missing, ref missing))
{
Console.WriteLine("Text found: Name document - " + "'" + docTitle + "'");
}
objDoc.Close(ref missing, ref missing, ref missing);
objWordApp.Application.Quit(ref missing, ref missing, ref missing);
}
catch (Exception ex)
{
objDoc.Close(ref missing, ref missing, ref missing);
objWordApp.Application.Quit(ref missing, ref missing, ref missing);
throw ex;
}
}
catch (Exception ex)
{
test11.Text = ex.ToString();
}
System.UnauthorizedAccessException: Retrieving the COM class factory for component with CLSID {000209FF-0000-0000-C000-000000000046} failed due to the following error: 80070005 Access denied. (Exception to HRESULT: 0x80070005 (E_ACCESSDENIED)).
I looked at a lot of information on the forums, did everything as written in the article, nothing helps, the error was not eliminated.
2.Retrieving the COM class factory for component with CLSID {000209FF-0000-0000-C000-000000000046}