none
C# Remoting RefObject do not works fine RRS feed

  • Question

  • Hi all,

    I am a newer in Remoting. Recently I want to to write a windows service with Remoting. 

    Below is the MarshalByRefObject I have defined. But when I call the fuction StartCapProcess() with correct the parameter from the client side this sentence "Application.Run(capform);" always failed.

    I have tried to call this function directly without using the Remoting. It works find.

    Can anyone tell me where is the problem?

    Thanks!

        public class TMCapture: MarshalByRefObject
        {          
            public Boolean StartCapProcess(string capPara)
            {
                TMTrace.Log("Start initial the capture process.");
                try
                {
                    string parameter = capPara;
                    int i = parameter.IndexOf(" ");
                    if (i != -1)
                    {
                        string[] Paras = parameter.Split(' ');
                        string portNo = Paras[0];
                        string capModel = Paras[1];
                        TMTrace.Log("The capture process is start with port number:" + portNo + " capture mode:" + capModel);
                        Form1 capform = new Form1(Convert.ToInt16(portNo), capModel);
                        Application.Run(capform);
                    }
                    TMTrace.Log("The capture process is finished.");
                    return true;
                }

                catch
                {
                    TMTrace.Log("Some error happened in the process of capture.");
                    return false;
                }
            }

            /// <summary>
            /// Helper for working with logging.
            /// </summary>
            internal static class TMTrace
            {
                public static void Log(string s)
                {
                    Log(TraceEventType.Information, s);
                }
                public static void Log(string format, params object[] parameters)
                {
                    Log(TraceEventType.Information, format, parameters);
                }
                public static void Log(TraceEventType severity, string format, params object[] parameters)
                {
                    Logger.Write(string.Format(format, parameters), "TMCaptureService", 0, 0, severity);
                }
            }
        }

    Friday, January 18, 2013 3:27 AM

All replies

  • Hi,

    Thanks for your post.

    I am trying to involve someone familiar with this topic to further look at this issue. There might be some time delay. Appreciate your patience.

    Best Regards.


    Haixia
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Tuesday, January 22, 2013 5:18 AM
    Moderator
  • We need to know the exact error that you are getting when you call Application.Run(capform).

    Can you share the error and the failure call stack?

    You can share a full building repro code with me for a check. Also what is the framework version that you are using?

    Please share your complete building code with me at cts-shmisra@live.com for a review.

    Thanks,

    Shamik

    Tuesday, February 12, 2013 5:39 PM