Hi all, I've found ways to do a binaryformatter, or a custom server sink, but not both together. Any ideas? I'm using binaryformatter with http on IIS, creating my server channel in code. Eventually (the whole point of this exercise) is to be able to pass an integer value in a modified IMessage from the ClientSink to the ServerSink. My problme is, as soon as I create a custom ServerSinkProvider, I lose my Binary Formatter. My code: 'Register Remote Channel Friend Sub RegisterRemoteChannel(ByVal psName As String, ByVal psPriority As String) Dim oColProps As Hashtable Dim oBinaryFormatter As BinaryServerFormatterSinkProvider Dim oChannel As HttpChannel WriteTrace() If (ChannelServices.GetChannel(psName) Is Nothing) Then 'Instantiate objects oColProps = New Hashtable oBinaryFormatter = New BinaryServerFormatterSinkProvider oBinaryFormatter.TypeFilterLevel = Runtime.Serialization.Formatters.TypeFilterLevel.Full 'Set Channel properties oColProps("name") = psName oColProps("priority") = psPriority 'Register channel WriteTrace("Register Channel") oChannel = New HttpChannel(oColProps, Nothing, oBinaryFormatter) ChannelServices.RegisterChannel(oChannel) End If End Sub TIA, Andy
Perhaps a better way to explain it: Could someone please convert this: <serverProviders> <formatter ref="binary" /> <provider type="MySinks.MyServerSinkProvider, MySinks" /> </serverProviders> to something like this: Dim oColProps As Hashtable Dim oBinaryFormatter As BinaryServerFormatterSinkProvider Dim oChannel As HttpChannel If (ChannelServices.GetChannel(psName) Is Nothing) Then 'Instantiate objects oColProps = New Hashtable oBinaryFormatter = New BinaryServerFormatterSinkProvider 'Set Channel properties oColProps("name") = psName oColProps("priority") = psPriority 'Register channel oChannel = New HttpChannel(oColProps, Nothing, oBinaryFormatter) ChannelServices.RegisterChannel(oChannel) End If C# is fine, I'm not picky. Again, TIA -Andy
Solution found (albeit in one of the more obscure sections of msdn): Literally, you build your own sink chain: Private Function CreateDefaultServerProviderChain() As IServerChannelSinkProvider Dim oSinkChain As BinaryServerFormatterSinkProvider Dim oSink As IServerChannelSinkProvider oSinkChain.TypeFilterLevel = Runtime.Serialization.Formatters.TypeFilterLevel.Full oSink = oSinkChain oSink.Next = New MySinks.MyServerSinkProvider oSink = oSink.Next Return oSinkChain End Function And the channel registration looks like this: oChannel = New HttpChannel(oColProps, Nothing, CreateDefaultServerProviderChain) Hope this helps anyone in the same spot I was. -Andy
Don't see what you're looking for? Try a search.
|