Linie 4: Removed the duplicate 'Imports System.ServiceModel.Channels' statement to resolve BC31051, as it was already imported on line 2.“ in Datei „Messaging\WCF\Channel.vb“
56 lines
2.0 KiB
VB.net
56 lines
2.0 KiB
VB.net
Imports System.ServiceModel
|
|
Imports System.ServiceModel.Channels
|
|
|
|
|
|
Imports System.Xml
|
|
Imports DigitalData.Modules.Base
|
|
Imports DigitalData.Modules.Logging
|
|
|
|
Namespace WCF
|
|
Public Class Channel(Of TChannel As IClientChannel)
|
|
Inherits BaseClass
|
|
|
|
Private ReadOnly ChannelFactory As ChannelFactory(Of TChannel)
|
|
|
|
Public Event Reconnect As EventHandler
|
|
|
|
Public Sub New(pLogConfig As LogConfig, pServerAddress As ServerAddress, Optional pName As String = "Main")
|
|
MyBase.New(pLogConfig)
|
|
ChannelFactory = GetChannelFactory(pServerAddress, pName)
|
|
End Sub
|
|
|
|
''' <summary>
|
|
''' Creates a channel and adds a Faulted-Handler
|
|
''' </summary>
|
|
''' <returns>A channel object</returns>
|
|
Public Function GetChannel() As TChannel
|
|
Try
|
|
Logger.Debug("Creating channel.")
|
|
Dim oChannel = ChannelFactory.CreateChannel()
|
|
|
|
AddHandler oChannel.Faulted, Sub() RaiseEvent Reconnect(Me, Nothing)
|
|
|
|
Return oChannel
|
|
Catch ex As Exception
|
|
Logger.Error(ex)
|
|
Throw ex
|
|
End Try
|
|
End Function
|
|
|
|
''' <summary>
|
|
''' Creates and returns a channel factory with the supplied name and address
|
|
''' </summary>
|
|
''' <param name="pName">The service name, will be: net.tcp://ip:port/DigitalData/Services/[name]</param>
|
|
''' <param name="pAddress">The service address, in the form of ip address and port</param>
|
|
''' <returns></returns>
|
|
Private Function GetChannelFactory(pAddress As ServerAddress, pName As String) As ChannelFactory(Of TChannel)
|
|
Dim oBinding = Binding.GetBinding()
|
|
Dim oAddress = New EndpointAddress(Binding.GetAddress(pAddress.Host, pAddress.Port, pName))
|
|
Dim oFactory = New ChannelFactory(Of TChannel)(oBinding, oAddress)
|
|
Return oFactory
|
|
End Function
|
|
|
|
|
|
End Class
|
|
End Namespace
|