none
COM Compliant .NET Assembly Error when making a call to an Azure web service RRS feed

  • Question

  • I have created a COM Compliant .NET Assembly that calls out to an Azure web service.  This Assembly will be called from a VB 6 Program (Yes I said VB 6.. Long Story).  Anyway, I have created COM Compliant Assemblies before to other web services and it was pretty straight forward to do.  However, not this time.  This time when I make a call to the DLL/Webservice from VB 6 I receive the error "An Error occurred while making the HTTP request to https:\... This could be due to the fact the server certificate is not configured properly with HTTP.SYS in the HTTPS Case.  This could also be caused by a mismatch of the security binding between the client and server."

    Using a Test .NET application calling the same methods, no error occurs and the DLL makes the necessary call to the web service.   To verify the .NET DLL was working correctly for COM, I added a simple function to add two numbers, which worked fine when called from the VB 6 application.  It is obviously an issue with COM and how it interacts with the web service.

    The code that is used for both VB 6 and VB .NET is

    Public Function TestService() As String
            Dim _REsult As String = ""
            Try
                Dim _proxy As PTWebService.ApsWebServicesClient = GetWebServiceClient(c_WSAddress)
                Dim _ctpRequest As PTWebService.CtpRequest = TestGetCTpRequest()
                Console.WriteLine($"Sending CTP Request with {_ctpRequest.CtpRequestLines.Length} Lines")
                Dim _Resp = _proxy.CTP("TestUser", "TestPwd", _ctpRequest)
    
                _REsult = $"Sent CTP Request with {_ctpRequest.CtpRequestLines.Length} Lines" & Environment.NewLine & $"CTP Response received with return code: {_Resp.ReturnCode}"
            Catch ex As Exception
                _REsult = "Error [" + ex.Message.ToString() + "]"
            End Try
    
            Return _REsult
        End Function
    
        Private Function TestGetCTpRequest() As PTWebService.CtpRequest
            Dim _ctpRequest As PTWebService.CtpRequest = New PTWebService.CtpRequest
    
            _ctpRequest.ReserveMaterialsAndCapacity = False
            _ctpRequest.SchedulingType = ESchedulingType.Optimize
    
            Dim ctpRequestLines As List(Of PTWebService.CtpRequestLine) = New List(Of PTWebService.CtpRequestLine)() From {
            New PTWebService.CtpRequestLine() With {
            .LineId = 1,
            .ItemExternalId = "FinishedGood 1",
            .WarehouseExternalId = "Main Warehouse",
            .RequiredQty = 100,
            .NeedDate = DateTime.Now.Add(TimeSpan.FromDays(7)),
            .Priority = 10
             }
            }
    
            _ctpRequest.CtpRequestLines = ctpRequestLines.ToArray
    
            Return _ctpRequest
        End Function
    
        Private Function GetWebServiceClient(c_WSAddress As String) As PTWebService.ApsWebServicesClient
    
            If c_WSAddress = "" Then
                Throw New Exception("No Address provided")
            End If
    
            Dim _Binding As BasicHttpBinding = New BasicHttpBinding(BasicHttpSecurityMode.Transport)
    
            With _Binding
                .BypassProxyOnLocal = True
                .CloseTimeout = New TimeSpan(0, 2, 0)
                .OpenTimeout = New TimeSpan(0, 2, 0)
                .SendTimeout = New TimeSpan(0, 2, 0)
                .AllowCookies = False
                .HostNameComparisonMode = HostNameComparisonMode.StrongWildcard
                .MaxBufferPoolSize = 524288
                .MaxBufferSize = Int32.MaxValue
                .MaxReceivedMessageSize = Int32.MaxValue
                .TextEncoding = Encoding.UTF8
                .TransferMode = TransferMode.Buffered
                .MessageEncoding = WSMessageEncoding.Text
    
            End With
    
            Return New PTWebService.ApsWebServicesClient(_Binding, New EndpointAddress(c_WSAddress))
        End Function
      This is the first time, I have made a call to an Azure web service, so compared to the other web services I have built interfaces for maybe I am missing something related to working Azure so it can work with VB 6.  Any suggestions would be appreciated.

    Lou Davis Software Engineer E2B Teknologies

    Friday, July 19, 2019 9:36 PM

Answers

  • Ok Sports Fans, as the 3rd party forum suggested the issue was the security protocol COM uses. (Ssl3 or Tls) which an Azure web service by default will not work with. The reason a .NET program works is due to the framework version I am using. 4.6 which defaults to the appropriate Security protocol that Azure recognizes.

    To work around the issue with COM, I executed the following code first in my routine that calls to the web service:

    If System.Net.ServicePointManager.SecurityProtocol = (SecurityProtocolType.Ssl3 Or SecurityProtocolType.Tls) Then System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls Or SecurityProtocolType.Tls11 Or SecurityProtocolType.Tls12

    End If

    This resulted in the VB 6 application being able to call the Azure web services successfully through the COM interface .NET Assembly and resolved the issue I was having. 


    Lou Davis Software Engineer E2B Teknologies

    • Marked as answer by e2bLou Thursday, July 25, 2019 2:07 PM
    Thursday, July 25, 2019 2:07 PM

All replies

  • Hi,

    If your issue is  related about asp.net,ask in the following forum:

    https://forums.asp.net/

    Best Regards,

    Alex


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, July 22, 2019 5:43 AM
  • No again this is a .NET Assembly which can be called through COM from VB 6.  This is a VB .NET Forum correct? 

    Lou Davis Software Engineer E2B Teknologies

    Monday, July 22, 2019 1:07 PM
  • So the ASP .NET Forum doesn't want to address this either.
    "Hello, You attempted
    to create a new thread on the ASP.NET Forums with the following message. Your
    question about VB 6 development is unrelated to the topic of the ASP.NET
    Forums. As a consequence, your message has not been approved. Perhaps you can
    use Bing.com to find a more relevant community service for your message. "

    So I'm back here as this again is a VB .NET Issue creating a COM Compliant .NET Assembly that needs to call out to an Azure web service.

    Lou Davis Software Engineer E2B Teknologies

    Monday, July 22, 2019 1:47 PM
  • Hi,

    This forum is discussing and asking questions about the vb.net,if your issue is more related about asp.net or vb6,you can ask in the following forum:

    VB6

    ASP.NET

    Best Regards,

    Alex


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Wednesday, July 24, 2019 2:27 AM
  • I beg to differ this is a client VB .NET Assembly we're talking about set up for COM. VB 6 calling it is irrelevant as any COM client including a C++ application could be used. The ASP .NET moderator agreed with me that this is not an asp .net issue.

    Using 3rd party forums that seem to assist developers better this forum, I learned this may be a TLS issue which is why when the assembly is called from a .NET Windows client it works but when instantiated through COM by the VB 6 Windows client it gets the error.  I will take their suggestion and look into using System.Net.ServicePointManager.SecurityProtocol to determine if the proper TLS is being used.  I will post my findings once I do this as an aid to other developers who might run into this issue.   I believe in sharing findings instead of brushing off requests for help because I don't know the answer or understand the problem. 

    Lou Davis Software Engineer E2B Teknologies

    Wednesday, July 24, 2019 1:11 PM
  • Ok Sports Fans, as the 3rd party forum suggested the issue was the security protocol COM uses. (Ssl3 or Tls) which an Azure web service by default will not work with. The reason a .NET program works is due to the framework version I am using. 4.6 which defaults to the appropriate Security protocol that Azure recognizes.

    To work around the issue with COM, I executed the following code first in my routine that calls to the web service:

    If System.Net.ServicePointManager.SecurityProtocol = (SecurityProtocolType.Ssl3 Or SecurityProtocolType.Tls) Then System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls Or SecurityProtocolType.Tls11 Or SecurityProtocolType.Tls12

    End If

    This resulted in the VB 6 application being able to call the Azure web services successfully through the COM interface .NET Assembly and resolved the issue I was having. 


    Lou Davis Software Engineer E2B Teknologies

    • Marked as answer by e2bLou Thursday, July 25, 2019 2:07 PM
    Thursday, July 25, 2019 2:07 PM