1

I am developing an Excel Add-In using Visual Studio Community 2022. The project commenced in May using a VS Project Template (Excel Web Add-In C#) as a starting point. The project has always side-loaded to Excel (desktop version) and run without issues. Recently Excel has begun throwing the following error in the Taskpane when I attempt to run the project from the VS IDE; "ADD-IN ERROR. The content is blocked because it isn't signed by a valid security certificate."

Screen grab of error

I initially assumed this was a straightforward error that meant the self-signed cert installed by Visual Studio when I first created the project had expired and needed to be renewed. I have since attempted multiple solutions (details below) but the error persists.

I have attempted the following to correct this:

Approach 1 - Manually delete certs and create in Visual Studio.

  1. Opened Certificate Manager and deleted all references to localhost and Microsoft Development certificates from all nodes.
  2. Flushed browser cache.
  3. Rebooted machine.
  4. Reopened Visual Studio and ran the project.
  5. Visual Studio recreates the certs and prompts me to self certify them for IIS Express.
  6. Confirmed the self certification.

Results: Same error in Excel. Visual Studio does not prompt to self certify on subsequent attempts suggesting the certs were successfully trusted.

Approach 2 - use office-addin-dev-certs npm package to self sign.

  1. Delete folder ".office-addin-dev-certs"

  2. Installed most recent package "npm install office-addin-dev-certs --save-dev"

  3. Create self signed localhost and CA certs "npx office-addin-dev-certs install"

  4. Verified the install "npx office-addin-dev-certs verify"

  5. Results of verify;

    You have trusted access to https://localhost. Certificate: C:\Users\Lloyd.office-addin-dev-certs\localhost.crt Key: C:\Users\Lloyd.office-addin-dev-certs\localhost.key

  6. Open Visual Studio and run project.

Results: Same error in Excel.

For good measure I have also tried deleting and reinstalling Office and have tried creating a new Excel Add-in from a code template with no customization.

Versions of components in use: Office 365: Version 2506 Build 16.0.18925.20076 64-bit Microsoft Visual Studio Community 2022: Version 17.14.8 Microsoft .NET Framework: Version 4.8.09032 ASP.NET and Web Tools 17.14.114.53116 Office Developer Tools for Visual Studio 17.10.35724.01

1

1 Answer 1

2

The problematic certificate was localhost.crt created under the Trusted Root Certification Authorities node in certmgr. I was deleting this certificate and allowing IIS Express to recreate it within Visual Studio as part of troubleshooting however what I did not realize was that the certificate was being created each time with an expiry date that had already passed. I have no idea why.

I uninstalled IIS Express 10 and reinstalled it (it was the same build), deleted the localhost.crt file again and reran my project from Visual Studio. This time the certificate was created with an expiry date of 2030 and the Excel add-in runs as expected.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.