>Using usingObject = New System.ServiceModel.OperationContextScope(loMyService.InnerChannel) > loSOAPSVC.oOperationContextScope = usingObject > . > . >end using >Don't think that's save. usingObject will be disposed when the using block exits and any subsequent use of loSOAPSVC.oOperationContextScope will be unsafe. I'd favour having SOAPSVC implement IDisposable. Something like:
Public Class SOAPSVC Implements IDisposable Public Property OperationContext() As OperationContext Get Return m_OperationContext End Get Set(value As OperationContext) m_OperationContext = value End Set End Property Private m_OperationContext As OperationContext Private isDisposed As Boolean = False Public Sub Dispose() Implements IDisposable.Dispose Dispose(True) GC.SuppressFinalize(Me) End Sub Protected Overridable Sub Dispose(disposing As Boolean) If Not isDisposed Then If disposing Then ' This ensures the contained object is disposed in a timely way Me.OperationContext.Dispose() isDisposed = True End If End If End Sub Protected Overrides Sub Finalize() Try Dispose(False) Finally MyBase.Finalize() End Try End Sub End Classthen just using:
Using svc As New SOAPSVC svc.OperationContext = New OperationContext End Using