Error HRESULT E_FAIL has been returned from a call to a COM component

Aashishkebab 5 Reputation points
2023-05-11T20:28:38.51+00:00

This works perfectly fine running locally and connecting to Azure database instance. But when I run it on App Service in Azure Cloud, I get this error on SqlConnection.Open()

Error HRESULT E_FAIL has been returned from a call to a COM component

What is going on here, and how do I resolve this?

Azure SQL Database
Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
8,960 questions
{count} vote

1 answer

Sort by: Most helpful
  1. Sedat SALMAN 14,180 Reputation points MVP
    2023-07-01T06:46:32.4466667+00:00

    https://stackoverflow.com/questions/13361199/error-hresult-e-fail-has-been-returned-from-a-call-to-a-com-component-vs2012-whe

    https://stackoverflow.com/questions/65864301/azure-db-connection-error-hresult-e-fail-has-been-returned-from-a-call-to-a-com

    Maybe these two links can help you, As a summary

    Deleting the .vs directory: Close your development environment (such as Visual Studio), navigate to your project's root folder, delete the .vs directory, and then reopen the solution and attempt to rebuild it.

    Deleting the solution's suo file: The suo file stores information about which files are open in the Integrated Development Environment (IDE). If the suo file is corrupt, it could cause the error you're encountering. You can delete this file without causing any significant damage to your project.

    Checking the referenced SQL client: In some cases, the issue might be due to referencing Microsoft.Data.SqlClient instead of System.Data.SqlClient in your project. Changing the reference back to System.Data.SqlClient might resolve the error.

    1 person found this answer helpful.
    0 comments No comments

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.