Signing with adxpatch.exe throws error

Add-in Express™ Support Service
That's what is more important than anything else

Signing with adxpatch.exe throws error
 
Ranjitha Nagendra




Posts: 8
Joined: 2021-01-11
Hello,

I have a COM addin and an XLL addin added to my solution. I am using clickonce deployment. Now I am trying to automate the build. Below is the sequence batch file to build the project and sign :

C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\MSBuild.exe MyExcelAddin.sln /t:Rebuild /nologo /v:minimal /p:Configuration=Release;TargetFrameworkVersion=v4.8;OutputPath=References\Bin
Copy Loader\adxloader.dll.manifest References\Bin
Copy Loader\adxloader.MyExcelAddIn.dll References\Bin
Copy Loader\adxloader64.MyExcelAddIn.dll References\Bin
References\Bin\adxpatch.exe /Sign="adxloader.dll.manifest" /CertificateFile="D:\Workarea\ExcelAddin\MyExcelAddin\MySign.pfx"
@echo Registring ExcelAddIn...
References\Bin\adxregistrator.exe /install="MyExcelAddIn.dll" /privileges="user"
@echo My Excel Addin built successfully.
@pause

I have created a folder References\Bin which has adxpatch.exe, adxregistrator.exe, adxpublisher.exe, adxpublisher.exe.config. Other reference dlls are copied after building the project.

Signing throws below error:

Update resources 'D:\Workarea\ExcelAddin\MyExcelAddin\References\Bin\adxloader.MyExcelAddin.dll'... success.
Update resources 'D:\Workarea\ExcelAddin\MyExcelAddin\References\Bin\adxloader64.MyExcelAddin.dll'... success.
Sign 'D:\Workarea\ExcelAddin\MyExcelAddin\References\Bin\MyExcelAddin.dll'... success.
Sign 'D:\Workarea\ExcelAddin\MyExcelAddin\References\Bin\adxloader.dll.manifest'... success.
Sign 'D:\Workarea\ExcelAddin\MyExcelAddin\References\Bin\adxloader.MyExcelAddin.dll'... failed.
adxpatch error: Failed to sign the 'D:\Workarea\ExcelAddin\MyExcelAddin\References\Bin\adxloader.MyExcelAddin.dll' file (HRESULT = -2147467259). HResult=-2147467259

Building from Visual studio works absolutely fine. But Building from Commandline throws this error. When I compared the files, manifest looks fine, the 2 Loader files are different. When I replace the Loader files generated from batch file with that of the files generated by Visual studio, it works fine.

Registering the dll from commandline throws no error (as seen in adxregistrator.log)

But launching excel does not load the addin and I see the below error in adxloader.log
15:43:44:622 5076 7028 Attempting to create a new instance of the managed XLL class: CLR - v4.0.30319
15:43:44:624 5076 7028 Hash verification failed

15:43:44:624 5076 7028 Hash verification failed

I have spent 2 days figuring out a solution, with no luck. Any help on this will be greatly appreciated.


Not sure if the below has any impact, building the project from commandline throws below warning as well :
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Current\Bin\Microsoft.Common.CurrentVersion.targe
ts(5148,5): warning MSB3061: Unable to delete file "D:\Workarea\ExcelAddin\MyExcelAddin\References\Bin\MyExcelAddin.dll". Access to the path 'D:\Workarea\ExcelAddin\MyExcelAddin\References\Bin\MyExcelAddin.dll' is denied. [D:\Workarea\ExcelAddin\MyExcelAddin\References\Bin\MyExcelAddin.sln]
Posted 15 May, 2021 06:49:13 Top
Andrei Smolin


Add-in Express team


Posts: 18219
Joined: 2006-05-11
Hello Ranjitha,

Ranjitha Nagendra writes:
Failed to sign the 'D:\Workarea\ExcelAddin\MyExcelAddin\References\Bin\adxloader.MyExcelAddin.dll' file (HRESULT = -2147467259). HResult=-2147467259


Try to start the batch file via "Run as administrator".

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 17 May, 2021 01:58:50 Top
Ranjitha Nagendra




Posts: 8
Joined: 2021-01-11
Hi Andrei,

I am already running as admin.
Posted 17 May, 2021 02:05:19 Top
Andrei Smolin


Add-in Express team


Posts: 18219
Joined: 2006-05-11
Hello Ranjitha,

Please confirm that you start the batch file from a CommandPrompt started via "Run as administrator".

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 17 May, 2021 02:54:29 Top
Ranjitha Nagendra




Posts: 8
Joined: 2021-01-11
I was running the batch file by right clicking and selecting Run as admin.

After you reply I now tried by starting the batch file from command prompt started via Run as admin

I see same error :-(
Posted 17 May, 2021 02:59:04 Top
Ranjitha Nagendra




Posts: 8
Joined: 2021-01-11
I am using a test key file (pfx) for signing. Ideally signing is not mandatory right, addin should be registered and work even without signing?

When I build from VS, manifest file is replaced everytime I build. Building the project from commandline does not replace the file. I am expecting that the additional action is performed by adxpatch. Please correct me if I am wrong in my understanding.
Posted 17 May, 2021 03:04:27 Top
Ranjitha Nagendra




Posts: 8
Joined: 2021-01-11
Building and registering from VS works absolutely fine. But I cant get it through my batch file for some reason. Any help will be greatly appreciated.
Posted 17 May, 2021 03:06:27 Top
Andrei Smolin


Add-in Express team


Posts: 18219
Joined: 2006-05-11
Hello Ranjitha,

Every time, before signing the adxloader*.dll files, copy them to your folder from the Add-in Express installation folder.


Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 18 May, 2021 04:45:18 Top
Ranjitha Nagendra




Posts: 8
Joined: 2021-01-11
Please can you make me understand why is that required? Also, I will be running this batch file on a machine where addinexpress will not be installed.
Posted 18 May, 2021 04:51:15 Top
Ranjitha Nagendra




Posts: 8
Joined: 2021-01-11
Automating the build is quite urgent for me at the moment. Looking forward to your reply. Any help in this regard will be greatly helpful.
Posted 18 May, 2021 10:34:19 Top