https webservices don't work in Excel plugin

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

https webservices don't work in Excel plugin
Webservices with http version work in my Add-in using https webservices does not work. 
Gerry Rempel




Posts: 3
Joined: 2009-07-10
I have an Excel Add-in that uses our public facing webservice to perform some operations. We have both a http and https version of this webservice. Both versions work, and can be called within my C# code in other applications. When I try to use the https version of webservice from the Excel Add-in I get this exception.

Exception thrown: 'System.IO.FileNotFoundException' in mscorlib.dll
'EXCEL.EXE' (CLR v4.0.30319: D:\code\sw\excel\addexpress\SwQuotes\SwQuotes\bin\Debug\): Loaded 'Microsoft.GeneratedCode'.
Exception thrown: 'System.Security.Authentication.AuthenticationException' in System.dll
Exception thrown: 'System.Security.Authentication.AuthenticationException' in System.dll
Exception thrown: 'System.Security.Authentication.AuthenticationException' in System.dll
Exception thrown: 'System.Security.Authentication.AuthenticationException' in System.dll
Exception thrown: 'System.Security.Authentication.AuthenticationException' in System.dll
Exception thrown: 'System.ObjectDisposedException' in System.dll
Exception thrown: 'System.Net.WebException' in System.dll
Exception thrown: 'System.Net.WebException' in System.dll
Exception thrown: 'System.Net.WebException' in System.Web.Services.dll

Is this a known bug, or do you have a solution. We need to move the to https call to future proof our application.

Thanks,
Gerry
Posted 08 Dec, 2020 14:56:28 Top
Andrei Smolin


Add-in Express team


Posts: 18338
Joined: 2006-05-11
Hello Gerry,

If this occurs on the target machine, this may relate to using an older .NET Framework version; I dimly remember an issue that was in some way similar to yours.

It seems however that the issue occurs on your development machine and I suppose you might provide more information.

Also, I have a bit of information that may relate to the issue^ When run from Excel, your add-in uses TLS 1.0. A while back I found that a VSTO add-in demonstrates the same behavior and googled out this page: Transport Layer Security (TLS) best practices with the .NET Framework #4675 on gthub/dotnet/docs; use Ctrl+F to find "Excel" on it.

You can specify the TLS to be used right in the constructor of the ADXClickOnceModule/ADXClickTwiceModule (you need to add them to your project) or in the constructor of the add-in module:

ServicePointManager.SecurityProtocol = 
     SecurityProtocolType.Tls11 | SecurityProtocolType.Tls12;


If you have no SecurityProtocolType.Tls11 and/or SecurityProtocolType.Tls12 declared in the .NET Framework version you are using, use numeric values:

ServicePointManager.SecurityProtocol = 
    SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls 
    | (SecurityProtocolType)768 /*Tls 1.1*/ 
    | (SecurityProtocolType)3072 /*Tls 1.2*/ 
    | (SecurityProtocolType)12288 /*Tls 1.3*/;


Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 09 Dec, 2020 02:30:47 Top
Gerry Rempel




Posts: 3
Joined: 2009-07-10
Andrei,

Thanks again, setting the SecurityProtocol in my Addin constructor was the solution I needed. It works like a charm now.

Thanks,
Gerry
Posted 09 Dec, 2020 13:39:56 Top
Andrei Smolin


Add-in Express team


Posts: 18338
Joined: 2006-05-11
You are welcome!

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 10 Dec, 2020 05:41:44 Top