开发者

Quick question TCP/IP .Net Remoting

I have a client application where i collect data and store it in a class Packet structure. Can I send the object of this class to my Server application?..Both application run on different machines connected by LAN network.

In .Net Remoting, where Object is instantiated in Server and Objref is shared with the Client. Now i have this object of class Packet as the remotable object, which is used as Client activated objects. The object is created when the client activates it.

public class Packet : MarshalByRefObject {
        public int svrnumber;
        public string svrname;
        [NonSerialized]
        public static IObserver Observer;

        public void MessageString(object value) {
                Observer.Notify(value);
        }

        public static void Attach(IObserver observer) {
            Observer = observer;
        }
    }

I refer the Pack(Object) of this class in client side and assign value.

            Pack.svrname = "Bob";
            Pack.svrnumber = 123456;

            sample = (Object)Pack;

Pass this sample object to Notify. I recieve this sample object at the server through the Notify function and unbox it to get my values.

By while i am calling the function MessageString, I get an exception as security restrictions Objref is not accessible!!

A开发者_如何学运维lso tell me whether there is any other approach to this issue.. Or should i use the SocketProgramming approach where i convert all my class values to bytes and then send across to server and then re-assign them.

Thanks.


I would use WCF approach, is done for this and does not imply remoting.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜