[Mono-bugs] [Bug 430213] New: Remote methods and events in C#

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Fri Sep 26 09:40:50 EDT 2008


https://bugzilla.novell.com/show_bug.cgi?id=430213


           Summary: Remote methods and events in C#
           Product: Mono: Compilers
           Version: 2.0
          Platform: HP
        OS/Version: Ubuntu
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: C#
        AssignedTo: mono-bugs at lists.ximian.com
        ReportedBy: marko.ceric at versor.si
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---


Description of Problem:
I did follow the tutorial
on:http://www.codeproject.com/KB/IP/csremoteevents1.aspx?msg=2740979.
I compiled and run the Server and all so compiled the mycomponent.dll without
problems.
The problem is in running Client.exe. I get: 

Subscribing

Unhandled Exception: System.IO.FileNotFoundException: Could not load file or
assembly 'Client' or one of its dependencies. The system cannot find the file
specified.
File name: 'Client'
  at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke
(System.Runtime.Remoting.Proxies.RealProxy rp, IMessage msg, System.Exception&
exc, System.Object[]& out_args) [0x00185] in
/build/buildd/mono-1.9.1+dfsg/mcs/class/corlib/System.Runtime.Remoting.Proxies/RealProxy.cs:227 


Steps to reproduce the problem:
1. Make the mycomponent.dll 
2. Compail and run Server.exe
3. Compail and run Client.exe 


Actual Results:
Error when running Client.exe: "Unhandled Exception:
System.IO.FileNotFoundException: Could not load file or assembly 'Client' or
one of its dependencies. The system cannot find the file specified.
File name: 'Client'
  at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke
(System.Runtime.Remoting.Proxies.RealProxy rp, IMessage msg, System.Exception&
exc, System.Object[]& out_args) [0x00185] in
/build/buildd/mono-1.9.1+dfsg/mcs/class/corlib/System.Runtime.Remoting.Proxies/RealProxy.cs:227 
"

Expected Results:
Event remoting.

How often does this happen? 


Additional Information:

The code:

mycomponent.dll

using System;

using System.Runtime.Remoting;



namespace mycomponent

{

        public delegate void myeventhandler(string str);



        /// <summary>

        /// Defines server interface which will be deployed on every client

        /// </summary>

        public  abstract class AbstractServer : MarshalByRefObject

        {

                public abstract string myfunc(string what);

                public abstract event  myeventhandler myevent;

        }



        //Defines the class that should have the sink in the server

        public abstract class AbstractBroadcastedMessageEventSink :
MarshalByRefObject

        {



                public void myCallback(string str)

                {

                        internalcallback(str);

                }



                protected abstract void internalcallback (string str) ;



        }



}



Server.exe

using System;

using mycomponent;

using System.Runtime.Remoting;
using System.Runtime.Remoting.Channels;

using System.Runtime.Remoting.Channels.Tcp;






namespace server

{

        class Class1

        {



                static void Main(string[] args)

                {

                        TcpChannel m_TcpChan = new TcpChannel(9999);


                        ChannelServices.RegisterChannel(m_TcpChan);


                        Type theType = new  ServerClass().GetType();  



                        RemotingConfiguration.RegisterWellKnownServiceType(

                                theType,

                                "FirstRemote",

                                WellKnownObjectMode.Singleton);



                        System.Console.WriteLine("Press ENTER to quit");

                        System.Console.ReadLine();

                }

        }



        public class ServerClass : AbstractServer

        {

                public override string myfunc(string what)

                {

                        Console.WriteLine("in myfunc");

                        FireNewBroadcastedMessageEvent("Event: " + what + " was
said");

                        return "Take " + what;

                }



                public event  myeventhandler myHandler;



                public override event myeventhandler myevent

                {

                        add

                        {

                                Console.WriteLine("in event myevent + add");



                                myHandler = value;

                        }



                        remove

                        {

                                Console.WriteLine("in event myevent + remove");

                        }

                }



                protected void FireNewBroadcastedMessageEvent(string text)

                {

                        Console.WriteLine("Broadcasting...");

                        myHandler("hai");

                }





        }



}





Client.exe


using System;



using System.Runtime.Remoting;

using System.Runtime.Remoting.Channels;

using System.Runtime.Remoting.Channels.Tcp;

using mycomponent;



namespace Client

{

        class EventSink : AbstractBroadcastedMessageEventSink

        {



                protected override  void internalcallback (string str) 

                {

                        Console.WriteLine("Your message in callback 2");

                }





        }



        class Class1

        {

                static void Main(string[] args)

                {

                        TcpChannel m_TcpChan = new TcpChannel(1111);

                        ChannelServices.RegisterChannel(m_TcpChan,false);





                        AbstractServer m_RemoteObject = (AbstractServer)

                               
Activator.GetObject(typeof(mycomponent.AbstractServer),

                                "tcp://192.168.1.75:9999/FirstRemote");







                        RemotingConfiguration.RegisterWellKnownServiceType(

                                typeof(Client.EventSink),

                                "ServerEvents",

                                WellKnownObjectMode.Singleton);



                        EventSink sink = new EventSink();       



                        Console.WriteLine("Subscribing");





                        m_RemoteObject.myevent += new
myeventhandler(sink.myCallback);




                        m_RemoteObject.myfunc("Hello");


                }

        }



}


-- 
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.


More information about the mono-bugs mailing list