Web Service Proxy Generator
OLE IDispatch exception code 0 from mscorlib: Exception has been thrown by the target of invocation
Gravatar is a globally recognized avatar based on your email address. OLE IDispatch exception code 0 from mscorlib: Exception has been thrown by the target of invocation
  obul b
  All
  Jun 9, 2021 @ 07:43pm

Hi Rick, I am getting "OLE IDispatch exception code 0 from mscorlib: Exception has been thrown by the target of invocation" error when calling vendor webservice using wwDotNetBridge.dll proxy generated by West Wind Web Service Proxy Generator from FoxPro9 program. It has been working fine for last few years but started failing from this monday(06/07/2021) when vendor has upgraded their security protocol to TLS1.2. This is on windows 7 server with 32 bit. We installed TLS1.2 as default protocol and .netframework4.8 on this windows 7 server after seeing some of your posts but still getting same issue. Also tried the below options but still facing the same issue. This error message "OLE IDispatch exception code 0 from mscorlib: Exception has been thrown by the target of invocation" is too generic to understand the actual root cause of the issue.

loBridge = CreateObject("wwDotNetBridge","V4")

*** I see 240 ? loBridge.GetStaticProperty("System.Net.ServicePointManager","SecurityProtocol")

loValue = loBridge.CreateComValue() loValue.SetEnum("System.Net.SecurityProtocolType.Tls12") loBridge.SetStaticProperty("System.Net.ServicePointManager","SecurityProtocol",loValue)

*** 3072 - TLS1.2 ? loBridge.GetStaticProperty("System.Net.ServicePointManager","SecurityProtocol")

Really appreciate your help in advace

Gravatar is a globally recognized avatar based on your email address. re: OLE IDispatch exception code 0 from mscorlib: Exception has been thrown by the target of invocation
  Rick Strahl
  obul b
  Jun 9, 2021 @ 08:25pm

If you're running the code you describe at the end of your message, and you check the value after you've set it and it's updated, then it should be working.

Also make sure you run that code at startup before any HTTP requests are run through the framework as the ServicePointManager is static singleton object in .NET.

If that gets set and it still doesn't work, it's possible that the problem is something completely different than TLS differences.

Note that even if you set the flags on Windows 7 you have to set the registry flags. Make sure that TLS 1.2 works otherwise on your machine using WinHTTP/WinInet (easiest is check with Internet Explorer on a page/site that you know requires TLS 1.2).

+++ Rick ---

Gravatar is a globally recognized avatar based on your email address. re: OLE IDispatch exception code 0 from mscorlib: Exception has been thrown by the target of invocation
  obr b
  Rick Strahl
  Jun 12, 2021 @ 11:01am

Thank you Rick. Appreciate your help. Tested as you instructed to make sure that TLS1.2 installed and also upgraded clrHost.dll,wwDotNetBridge.dll and wwDotNetBridge.prg libraries and files. Now looks like "OLE IDispatch exception code 0 from mscorlib: Exception has been thrown by the target of invocation" error is gone and our program is able to hit the vendor SOAP web service. Also generated new proxy using latest "West Wind Web Service Proxy Generator" and WSDL

Gravatar is a globally recognized avatar based on your email address. re: OLE IDispatch exception code 0 from mscorlib: Exception has been thrown by the target of invocation
  Rick Strahl
  obr b
  Jun 12, 2021 @ 11:34am

Yeah it's always a good idea to download a current version, when you run into problems especially with system issues like TLS.

wwDotnetBridge got updated a while back to automatically set the correct TLS defaults and that's likely what made this work, although manual code update of the value should have also done the trick.

Glad you got it working.

+++ Rick ---

© 1996-2024