John Kotuby
9/20/2004 2:21:00 AM
figured it out....
on the client side ... use BinaryClientFormatterSinkProvider
next question though, is why I need it?
"JohnK" wrote:
> when button1_Click is executed, I get this msg
> ==============================================
> An unhandled exception of type 'System.Runtime.Remoting.RemotingException'
> occurred in mscorlib.dll
>
> Additional information: This remoting proxy has no channel sink which means
> either the server has no registered server channels that are listening, or
> this application has no suitable client channel to talk to the server.
> =====================================================
> namespace RemotingServerAug28
> {
> public class BroadCaster: System.MarshalByRefObject, IBroadCaster
> {
> public event RemotingObject.EventHandlerDelegate EventHandler1;
>
> public void BroadCastMessage(string msg)
> {
> EventHandler1(msg);
> }
> public override object InitializeLifetimeService()
> {
> return null; // this object must live forever
> }
> }
>
>
> class ServerAug28
> {
> [STAThread]
> static void Main(string[] args)
> {
> // Creating a custom formatter for a TcpChannel sink chain.
> BinaryServerFormatterSinkProvider provider = new
>
> BinaryServerFormatterSinkProvider();
>
> provider.TypeFilterLevel = TypeFilterLevel.Full;
>
> // Creating the IDictionary to set the port on the channel instance.
> IDictionary props = new Hashtable();
> props["port"] = 8086;
> // Pass the properties for the port setting and the server provider in
> the server
> // chain argument. (Client remains null here.)
> TcpChannel chan = new TcpChannel(props, null, provider);
> RemotingConfiguration.RegisterWellKnownServiceType(
> typeof(BroadCaster),
> "MyUri",
> WellKnownObjectMode.Singleton);
>
> Console.WriteLine("Press enter to stop this process.");
> Console.ReadLine();
> }
> }
> }
> ==============================================
> static void Main()
> {
> Application.Run(new Form1());
> }
>
> private void button1_Click(object sender, System.EventArgs e)
> {
> RemObj.BroadCastMessage("Hello World. This is a Broadcasted msg");
> }
>
> private void Form1_Load(object sender, System.EventArgs e)
> {
> TcpChannel chan = new TcpChannel();
> ChannelServices.RegisterChannel(chan);
>
> RemotingConfiguration.RegisterWellKnownClientType( typeof(IBroadCaster), "tcp://Localhost:8086/HelloServiceApplication/MyUri");
>
> RemObj = (IBroadCaster)Activator.GetObject(typeof(IBroadCaster),
> "tcp://Localhost:8086/HelloServiceApplication/MyUri");
>
> RemObj2 = new NameAddressClass();
>
> bool ff = RemotingServices.IsTransparentProxy(RemObj);
> ff = RemotingServices.IsTransparentProxy(RemObj2);
>
> RemObj2.EventHandler2 +=new EventHandlerDelegate
>
> (RemObj2_EventHandler2);
>
> RemObj.EventHandler1 +=new EventHandlerDelegate(RemObj2.FooFoo);
>
> } //Form1_Load
>
> public static void RemObj2_EventHandler2(string msg)
> {
> MessageBox.Show(msg);
> }
>
> ================================================
> namespace RemotingObject
> {
> public delegate void EventHandlerDelegate(string msg);
>
> public interface IBroadCaster
> {
> void BroadCastMessage(String msg);
> event EventHandlerDelegate EventHandler1;
> }
>
> public class NameAddressClass : System.MarshalByRefObject
> {
> public event EventHandlerDelegate EventHandler2;
>
> public NameAddressClass()
> {
> }
>
> [OneWay]
> public void FooFoo(string msg)
> {
> //forward the message to the client
> EventHandler2(msg);
> }
> }
> }
>