I haven't done this myself, but when I asked the same question a while
ago, I was told the solution was to write a custom IFormatProvider
implementation and register it in your .config file (or
programmatically) instead of the built-in format provider.

So instead of listing the built-in formatter provider in your config
file like so (using binary as an example):

<formatter ref="binary"/>

you'd list your own there instead:

<formatter type="YourNamespace.YourFormatProvider, YourAssembly, ..." />

Then YourFormatProvider would implement IFormatProvider.GetFormat so
that it instantiated your serialization surrogate, instantiated the
built-in BinaryFormatter passing in your serialization surrogate to it,
and then returns the reference to the newly initialized binary
formatter.

Hopefully that gets you on your way...

-Mike
DevelopMentor
http://staff.develop.com/woodring


> -----Original Message-----
> From: Moderated discussion of advanced .NET topics.
> [mailto:[EMAIL PROTECTED] On Behalf Of
> Abdulla, Jehangir
> Sent: Monday, March 03, 2003 7:09 AM
> To: [EMAIL PROTECTED]
> Subject: [ADVANCED-DOTNET] Passing a Surrogate to the
> BinaryFormatter used by the Remoting infrastructure
>
>
> This may be a stupid question, I need to pass a Surrogate
> Selector to the BinaryFormatter that is used by the Remoting
> infrastructure, any ideas on how this can be done. I thought
> maybe the BinaryClientFormatterSink or the
> BinaryServerFormatterSink would have a property that allows
> me access to the Formatter but that wasn't the case.
> On the same note, if I can pass in my own SurrogateSelector I
> could also pass in my own custom Binder to the Formatter ?
> Any ideas guys on how this can be done ?
> Thanks,
> John
>

Reply via email to