开发者

Activator.GetObject - Using the state parameter

In .NET Remoting, Activator.GetObject method has a state parameter. What is the purpose of this state param? Can I retrieve its value from server side?

mdsn didn't help much.

What I'd like to do:

Clie开发者_运维问答nt side:

ChannelServices.RegisterChannel(new TcpChannel(0));

object obj = Activator.GetObject(typeof(MyObj), "tcp://serverName:1234/RemoteObj", "myCustomData");

Server side:

Get access to the "myCustomData" string.


I'm not entirely sure what the purpose of this state field is but it appears to be a channel specific value that's not of use to your code. In tracing through Activator.GetObject in Reflector you'll notice that it eventually gets passed to IChannelSender.CreateMessageSink. The use of this data is implementation specific.

A quick search revealed only one implementor if IChannelSender: CrossAppDomainChannel. In this particular implementation the state parameter is only used if it is of a particular type: CrossAppDomainData. This is an internal class which is not accessible to your program and hence is of no use.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜