Il problema più grande era che nel passare il codice del link da C# a VB.Net il convertitore che avevo usato (il telerik) aveva "tradotto" come "Inherits" quelli che dovevano essere invece degli "Implements"
Correggendo quello poi il Visual Studio ha riscritto da solo tutte le "Public Sub" delle classi ed io ci ho ri-aggiunto le parti personalizzate e commentato tutti i "Throw New NotImplementedException()"
Non essendo esperto per me è stata un'impresa!
Ecco le due classi complete
AddUserAgentEndpointBehavior.vb
Codice sorgente - presumibilmente VB.NET |
Imports System.ServiceModel.Channels Imports System.ServiceModel.Description Imports System.ServiceModel.Dispatcher Public Class AddUserAgentEndpointBehavior Implements IEndpointBehavior Public Sub AddBindingParameters(endpoint As ServiceEndpoint, bindingParameters As BindingParameterCollection) Implements IEndpointBehavior.AddBindingParameters 'Throw New NotImplementedException() End Sub Public Sub ApplyClientBehavior(endpoint As ServiceEndpoint, clientRuntime As ClientRuntime) Implements IEndpointBehavior.ApplyClientBehavior clientRuntime.MessageInspectors.Add(New AddUserAgentClientMessageInspector()) 'Throw New NotImplementedException() End Sub Public Sub ApplyDispatchBehavior(endpoint As ServiceEndpoint, endpointDispatcher As EndpointDispatcher) Implements IEndpointBehavior.ApplyDispatchBehavior 'Throw New NotImplementedException() End Sub Public Sub Validate(endpoint As ServiceEndpoint) Implements IEndpointBehavior.Validate 'Throw New NotImplementedException() End Sub End Class
|
AddUserAgentClientMessageInspector.vb
Codice sorgente - presumibilmente VB.NET |
Imports System.ServiceModel Imports System.ServiceModel.Channels Imports System.ServiceModel.Dispatcher Public Class AddUserAgentClientMessageInspector Implements IClientMessageInspector Private Function IClientMessageInspector_BeforeSendRequest(ByRef request As Message, channel As IClientChannel) As Object Implements IClientMessageInspector.BeforeSendRequest Dim Myproperty As HttpRequestMessageProperty = New HttpRequestMessageProperty() Dim userAgent = "Azienda1" Myproperty = New HttpRequestMessageProperty() Myproperty.Headers("CustomerName") = userAgent request.Properties.Add(HttpRequestMessageProperty.Name, Myproperty) Return Nothing 'Throw New NotImplementedException() End Function Private Sub IClientMessageInspector_AfterReceiveReply(ByRef reply As Message, correlationState As Object) Implements IClientMessageInspector.AfterReceiveReply 'Throw New NotImplementedException() End Sub End Class
|
Ultima modifica effettuata da dylan666 il 01/02/2022 alle 8:59