InstanceContextMode.Single + OperationContext.Current

  • Thread starter Thread starter sandrofurlan
  • Start date Start date
S

sandrofurlan

Hi all,
i have a WCF service for USB communication. I need to instance it as a
singleton class so i do:

<ServiceBehavior(InstanceContextMode:=InstanceContextMode.Single, _
ConcurrencyMode:=ConcurrencyMode.Multiple)> _
Public Class myService

....

End class

And that's OK! But I also need do define callbacks to signal events so
I add a callback Interface and:

<ServiceContract(NameSpace:="http://Microsoft.Services", _
SessionMode:=SessionMode.Required, _
CallbackContract:=GetType(ImyCallback))> _
Public Interface IService

...

end Interface

The problem is in the constructor method of Service'class where I've
to get the InstanceContext for the CallbackChannel. I got an exception
in this code:

public sub new

callback = OperationContext.Current.GetCallbackChannel(Of
IEasyBusCallback)() '<-Reference to an object not set up on an object
request

end sub

Note that class myService inherits another class that implements
communication

thanks
 
Back
Top