Also talk about event processing in DOTNET Remoting

xiaoxiao2021-03-06  65

Have a friend mentioned the problem of event processing in transoting, I got, I found a few useful articles. Big bad guy DOTNET Remoting event Http://blog.joycode.com/joe/archive/2004/11/09/38437.aspx Create a distributed application structure based on Microsoft .NET Remoting Luxi http: // www .microsoft.com / china / community / column / 62.mspx thinking is simple, if you go to mimic writing one, it is easy to make mistakes. Probably the idea: the so-called subscription release model, one premise is that the program must be stateful. This is important, so it should be, so HTTP Web Service cannot directly implement the event model. For Remoting events, you must also ensure that the remote object is stateful. So if you activate the server, you must be a Singleton model. If SingleCall, you will find that there is no problem in program debugging. Event handler speakers are not in turn :) Be son is easy to encounter mistakes

An Unhandled Exception of Type 'System.Security.securityException' occurred in mscorlib.dll

Additional Information: Type System.delegateSerializationHolder and the Types derived from it (Such as system.delegateserizationHolder) Are Not Permitted to be Deserialized At this security level.

This problem is a big bad guy, as long as the TypefilterLevel for the Formatter channel in the program or hardcodes set the server CHANNELSINK. Such as code VB.NET

DIM

Chan2

AS

Httpchannel Chan2

=

New

Httpchannel

8086

)

DIM

IC

AS

IServerChannelSink

=

Chan2.channelsinkchain

While

NOT

(IC

IS

Nothing

)

IF

Typeof

(IC)

IS

SOAPSERVERFORMATTERSINK

THEN

Ctype

(IC, SOAPSERVERFORMATTERSINK) .TYPEFILTERLEVEL

=

Runtime.Serialization.Formatters.typefilterLevel.Full

End

IF

IF

Typeof

(IC)

IS

BinaryServerFormattersink

THEN

Ctype

(IC, binaryserverformattersink .typefilterLevel

=

Runtime.Serialization.Formatters.typefilterLevel.Full

End

IF

IC

=

Ic.nextChannelSink

End

While

C #

Httpchannel Chan2

=

New

Httpchannel

8086

IServerChannelSink SC

=

Chan2.channeelsinkchain;

While

(SC

! =

NULL

)

{If (sc is BinaryServerFormatterSink) {((BinaryServerFormatterSink) sc) .TypeFilterLevel = TypeFilterLevel.Full;} if (sc is SoapServerFormatterSink) {((SoapServerFormatterSink) sc) .TypeFilterLevel = TypeFilterLevel.Full;} sc = sc.NextChannelSink;} Of course, the server can set it with an easy-to-make mistake:

N 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.

This will change the client's Channel port number to 0, so that the system will "toss".

DIM CHAN As httpchannel chan = new httpchannel (0)

转载请注明原文地址:https://www.9cbs.com/read-90849.html

New Post(0)