Questo post analizza un errore a runtime di .NET Remoting.
WCF sta rapidamente diventando l’infrastruttura di comunicazione preferita per le applicazioni .NET, ma .NET Remoting è ancora utile in alcuni casi. Specificamente, quando l’interoperabilità non è richiesta ed è necessario passare gli oggetti per riferimento invece che per valore.
A runtime, un client .NET Remoting riceve una eccezione RemotingException durante la chiamata ad un oggetto remoto di tipo Server.Obj. L’oggetto remoto viene acceduto tramite un canale TCP.
L’eccezione completa ricevuta dal client è la seguente:
Unhandled Exception: System.Runtime.Remoting.RemotingException: 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. at System.Runtime.Remoting.Proxies.RemotingProxy.InternalInvoke(IMethodCallMessage reqMcmMsg, Boolean useDispatchMessage, Int32 callType) at System.Runtime.Remoting.Proxies.RemotingProxy.Invoke(IMessage reqMsg) at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) at Itfs.IObj.DoNothing() at Client.Program.Main()
Nota: il problema riportato dal cliente si verificava in una applicazione piuttosto complessa. Nel seguito usiamo un esempio molto più semplice per poterci focalizzare solo sul problema in oggetto. Useremo tuttavia le stesse tecniche di troubleshooting che avremmo usato in applicazioni complesse, delle quali non abbiamo conoscenza del codice: invece di partire con un’analisi esaustiva del codice sorgente, che richiede troppo tempo, partiremo dall’eccezione e dall’ analisi delle strutture dati usate da .NET Remoting a runtime per trovare il problema. Sì, avete indovinato : questo significa analizzare dump con il debugger WinDbg e la debugger extension sos.
Il messaggio dell’eccezione è piuttosto accurato: oltre a descrivere il problema (the proxy does not have a channel sink), riporta anche 2 possibili cause: il server non ha un canale server registrato, oppure il client non dispone di un canale client adatto. Per comprendere il significato di questi messaggi, abbiamo bisogno di alcune nozioni su come funzionano i canali in .NET Remoting. Più avanti useremo queste info per il nostro troubleshooting.
I canali di .NET Remoting sono classi che implementano l’interfaccia IChannel. Sono registrati per-AppDomain mediante ChannelServices.RegisterChannel(). Esistono in realtà 2 tipi di canali: i “receiver channel” implementano IChannelReceiver, i “sender channel” implementano IChannelSender. Possono anche essere chiamati “canali server” e “canali client”, rispettivamente - è la terminologia che useremo nel seguito. TcpServerChannel e HttpServerChannel sono canali server, mentre TcpClientChannel e HttpClientChannel sono canali client. .NET Remoting sceglie il canale di comunicazione in questo modo: quando un riferimento ad un oggetto MarshalByRefObject viene “trasferito” al di fuori del proprio AppDomain, l’ObjRef contiene informazioni sui canali server registrati in quell’AppDomain, in ordine di priorità (proprietà IChannel.ChannelPriority). Quando l’oggetto ObjRef viene deserializzato nel client, ogni canale client registrato nell’AppDomain corrente viene interrogato (in ordine di priorità) per verificare se può gestire l’URL contenuto nella sezione channelData dell’ObjRef. Viene usato il primo canale che risponde positivamente.
.NET Remoting registra implicitamente i canali client TCP e HTTP, se non sono registrati esplicitamente.
Il canale CrossAppDomainChannel, non documentato, è anch’esso automaticamente registrato, in modo da permettere l’utilizzo di .NET Remoting attraverso AppDomain diversi nello stesso processo.
Infine, le classi TcpChannel e HttpChannel, implementando sia IChannelReceiver che IChannelSender, svolgono il ruolo sia di canali client che di canali server.
Partiamo dal dump del client, il processo che riceve l’eccezione RemotingException. Per questo tipo di problema e di applicazione, l’analisi del dump è più veloce che un’analisi esaustiva del codice, come già riportato sopra.
Esiste, in realtà, un altro motivo per partire dall’analisi di un dump, vale a dire dall’analisi delle strutture dati del .NET Remoting a runtime: le configurazioni .NET possono essere fatte in 2 modi: imperativo nel codice, o dichiarativo nei file di configurazione. La configurazione di .NET Remoting segue anch’essa questa logica, pertanto i canali e le altre informazioni di configurazioni possono trovarsi SIA nel codice CHE nei config files. Diventa quindi complicato capire, dall’analisi dei file sorgente e di configurazione, quale sarà la reale configurazione a runtime.
Note: alcune delle strutture dati che analizzeremo nei dump sono interne e soggette a modifica nelle prossime versioni della .NET Framework. L’analisi che segue si applica alle versioni 2.0-3.5 della .NET Framework.
Iniziamo a verificare che il client ha solo il default AppDomain, oltre al System Domain e al Shared Domain, che sono AppDomain di sistema:
0:000> !dumpdomain--------------------------------------System Domain: 6e4ce1f8LowFrequencyHeap: 6e4ce21cHighFrequencyHeap: 6e4ce268StubHeap: 6e4ce2b4Stage: OPENName: None--------------------------------------Shared Domain: 6e4cdb48LowFrequencyHeap: 6e4cdb6cHighFrequencyHeap: 6e4cdbb8StubHeap: 6e4cdc04Stage: OPENName: NoneAssembly: 002e72d0--------------------------------------Domain 1: 002a1df8LowFrequencyHeap: 002a1e1cHighFrequencyHeap: 002a1e68StubHeap: 002a1eb4Stage: OPENSecurityDescriptor: 002a3120Name: Client.exeAssembly: 002e72d0 [C:\Windows\assembly\GAC_32\mscorlib\2.0.0.0__b77a5c561934e089\mscorlib.dll]ClassLoader: 002e7350SecurityDescriptor: 002e3900 Module Name6d481000 C:\Windows\assembly\GAC_32\mscorlib\2.0.0.0__b77a5c561934e089\mscorlib.dll00272358 C:\Windows\assembly\GAC_32\mscorlib\2.0.0.0__b77a5c561934e089\sortkey.nlp00272010 C:\Windows\assembly\GAC_32\mscorlib\2.0.0.0__b77a5c561934e089\sorttbls.nlp...
0:000> !dumpheap -type RegisteredChannelList Address MT Size01f448f0 6d6cc1bc 12 01f449a4 6d6cc1bc 12 01f44ad0 6d6cc1bc 12 total 3 objectsStatistics: MT Count TotalSize Class Name6d6cc1bc 3 36 System.Runtime.Remoting.Channels.RegisteredChannelListTotal 3 objects0:000> !gcroot 01f448f0Note: Roots found on stacks may be false positives. Run "!help gcroot" formore info.Scan Thread 0 OSTHread 1164Scan Thread 2 OSTHread 267cScan Thread 3 OSTHread 1f88Scan Thread 7 OSTHread 235c0:000> !gcroot 01f449a4Note: Roots found on stacks may be false positives. Run "!help gcroot" formore info.Scan Thread 0 OSTHread 1164Scan Thread 2 OSTHread 267cScan Thread 3 OSTHread 1f88Scan Thread 7 OSTHread 235c0:000> !gcroot 01f44ad0Note: Roots found on stacks may be false positives. Run "!help gcroot" formore info.Scan Thread 0 OSTHread 1164Scan Thread 2 OSTHread 267cScan Thread 3 OSTHread 1f88Scan Thread 7 OSTHread 235cDOMAIN(002A1DF8):HANDLE(Pinned):1313fc:Root:02eb1010(System.Object[])->01f44ad0(System.Runtime.Remoting.Channels.RegisteredChannelList)
0:000> !do 01f44ad0Name: System.Runtime.Remoting.Channels.RegisteredChannelListMethodTable: 6d6cc1bcEEClass: 6d4a2ee4Size: 12(0xc) bytes (C:\Windows\assembly\GAC_32\mscorlib\2.0.0.0__b77a5c561934e089\mscorlib.dll)Fields: MT Field Offset Type VT Attr Value Name6d6c4eec 4001f1d 4 System.Object[] 0 instance 01f44aa8 _channels0:000> !da 01f44aa8 Name: System.Runtime.Remoting.Channels.RegisteredChannel[]MethodTable: 6d6c4eecEEClass: 6d4aa8a0Size: 24(0x18) bytesArray: Rank 1, Number of elements 2, Type CLASSElement Methodtable: 6d6cc204[0] 01f44ac0[1] 01f449940:000> !do 01f44ac0Name: System.Runtime.Remoting.Channels.RegisteredChannelMethodTable: 6d6cc204EEClass: 6d507784Size: 16(0x10) bytes (C:\Windows\assembly\GAC_32\mscorlib\2.0.0.0__b77a5c561934e089\mscorlib.dll)Fields: MT Field Offset Type VT Attr Value Name6d6cc248 4001f1b 4 ...Channels.IChannel 0 instance 01f44a4c channel6d6eb3e0 4001f1c 8 System.Byte 1 instance 3 flags0:000> !do 01f44a4c Name: System.Runtime.Remoting.Channels.CrossAppDomainChannelMethodTable: 6d6cc0e4EEClass: 6d507720Size: 12(0xc) bytes (C:\Windows\assembly\GAC_32\mscorlib\2.0.0.0__b77a5c561934e089\mscorlib.dll)Fields: MT Field Offset Type VT Attr Value Name6d6e84dc 4001f7e 664 System.Object 0 shared static staticSyncObject >> Domain:Value 002a1df8:01f44a58 <<6d6ea584 4001f7f 668 ...ity.PermissionSet 0 shared static s_fullTrust >> Domain:Value 002a1df8:01f44a64 <<0:000> !do 01f44994Name: System.Runtime.Remoting.Channels.RegisteredChannelMethodTable: 6d6cc204EEClass: 6d507784Size: 16(0x10) bytes (C:\Windows\assembly\GAC_32\mscorlib\2.0.0.0__b77a5c561934e089\mscorlib.dll)Fields: MT Field Offset Type VT Attr Value Name6d6cc248 4001f1b 4 ...Channels.IChannel 0 instance 01f4487c channel6d6eb3e0 4001f1c 8 System.Byte 1 instance 3 flags0:000> !do 01f4487c Name: System.Runtime.Remoting.Channels.Tcp.TcpChannelMethodTable: 61f476f4EEClass: 61eb5becSize: 24(0x18) bytes (C:\Windows\assembly\GAC_MSIL\System.Runtime.Remoting\2.0.0.0__b77a5c561934e089\System.Runtime.Remoting.dll)Fields: MT Field Offset Type VT Attr Value Name61f47794 4000160 4 ....TcpClientChannel 0 instance 01f448ac _clientChannel61f4781c 4000161 8 ....TcpServerChannel 0 instance 00000000 _serverChannel6d6eab0c 4000162 10 System.Int32 1 instance 1 _channelPriority6d6e88c0 4000163 c System.String 0 instance 01f44894 _channelName
Sappiamo che l’oggetto di remoting nel server è di tipo Server.Obj. Vediamo a che AppDomain appartiente:
0:013> !dumpheap -type Server.Obj Address MT Size01d79960 03d035a8 12 total 1 objectsStatistics: MT Count TotalSize Class Name03d035a8 1 12 Server.ObjTotal 1 objects0:013> !dumpmt 03d035a8EEClass: 03d012f0Module: 03d02d68Name: Server.ObjmdToken: 02000004 (d:\MSDNBlog\RemotingExceptionWithChannels\Repro\Server\bin\Debug\Server.exe)BaseSize: 0xcComponentSize: 0x0Number of IFaces in IFaceMap: 1Slots in VTable: 90:013> !dumpmodule 03d02d68Name: d:\MSDNBlog\RemotingExceptionWithChannels\Repro\Server\bin\Debug\Server.exeAttributes: PEFile Assembly: 00490bb0LoaderHeap: 00000000TypeDefToMethodTableMap: 03d00038TypeRefToMethodTableMap: 03d0004cMethodDefToDescMap: 03d000d0FieldDefToDescMap: 03d000ecMemberRefToDescMap: 03d000f4FileReferencesMap: 03d00178AssemblyReferencesMap: 03d0017cMetaData start address: 010f211c (2380 bytes)0:013> !dumpassembly 00490bb0Parent Domain: 004d4880Name: d:\MSDNBlog\RemotingExceptionWithChannels\Repro\Server\bin\Debug\Server.exeClassLoader: 00490c20SecurityDescriptor: 004f4600 Module Name03d02d68 d:\MSDNBlog\RemotingExceptionWithChannels\Repro\Server\bin\Debug\Server.exe
Abbiamo trovato l’AppDomain partendo dall’oggetto e passando attraverso la sua MethodTable, il modulo e l’assembly. L’AppDomain ha indirizzo 0x004d4880.
In modo del tutto analogo a quanto fatto in precedenza per il client, analizziamo il contenuto degli oggetti RegisteredChannelList per ogni AppDomain:
0:013> !dumpheap -type RegisteredChannelList Address MT Size01d30ffc 6d6cc1bc 12 01d3422c 6d6cc1bc 12 01d4727c 6d6cc1bc 12 01d4b554 6d6cc1bc 12 01d71758 6d6cc1bc 12 01d71798 6d6cc1bc 12 total 6 objectsStatistics: MT Count TotalSize Class Name6d6cc1bc 6 72 System.Runtime.Remoting.Channels.RegisteredChannelListTotal 6 objects0:013> !gcroot 01d30ffcNote: Roots found on stacks may be false positives. Run "!help gcroot" formore info.Scan Thread 0 OSTHread 1254Scan Thread 2 OSTHread 11f4Scan Thread 6 OSTHread 2380Scan Thread 7 OSTHread 1904Scan Thread 9 OSTHread 1130Scan Thread 10 OSTHread 221cScan Thread 12 OSTHread 2424Scan Thread 11 OSTHread 1594DOMAIN(0044A330):HANDLE(Pinned):1713fc:Root:02d01010(System.Object[])->01d30ffc(System.Runtime.Remoting.Channels.RegisteredChannelList)0:013> !gcroot 01d3422cNote: Roots found on stacks may be false positives. Run "!help gcroot" formore info.Scan Thread 0 OSTHread 1254Scan Thread 2 OSTHread 11f4Scan Thread 6 OSTHread 2380Scan Thread 7 OSTHread 1904Scan Thread 9 OSTHread 1130Scan Thread 10 OSTHread 221cScan Thread 12 OSTHread 2424Scan Thread 11 OSTHread 1594DOMAIN(004A4908):HANDLE(Pinned):8112fc:Root:02d06280(System.Object[])->01d3422c(System.Runtime.Remoting.Channels.RegisteredChannelList)0:013> !gcroot 01d4727c Note: Roots found on stacks may be false positives. Run "!help gcroot" formore info.Scan Thread 0 OSTHread 1254Scan Thread 2 OSTHread 11f4Scan Thread 6 OSTHread 2380Scan Thread 7 OSTHread 1904Scan Thread 9 OSTHread 1130Scan Thread 10 OSTHread 221cScan Thread 12 OSTHread 2424Scan Thread 11 OSTHread 1594DOMAIN(004BB1D0):HANDLE(Pinned):9412fc:Root:02d086a0(System.Object[])->01d4727c(System.Runtime.Remoting.Channels.RegisteredChannelList)0:013> !gcroot 01d4b554 Note: Roots found on stacks may be false positives. Run "!help gcroot" formore info.Scan Thread 0 OSTHread 1254Scan Thread 2 OSTHread 11f4Scan Thread 6 OSTHread 2380Scan Thread 7 OSTHread 1904Scan Thread 9 OSTHread 1130Scan Thread 10 OSTHread 221cScan Thread 12 OSTHread 2424Scan Thread 11 OSTHread 1594DOMAIN(004C3D18):HANDLE(Pinned):db12fc:Root:02d096b0(System.Object[])->01d4b554(System.Runtime.Remoting.Channels.RegisteredChannelList)0:013> !gcroot 01d71758 Note: Roots found on stacks may be false positives. Run "!help gcroot" formore info.Scan Thread 0 OSTHread 1254Scan Thread 2 OSTHread 11f4Scan Thread 6 OSTHread 2380Scan Thread 7 OSTHread 1904Scan Thread 9 OSTHread 1130Scan Thread 10 OSTHread 221cScan Thread 12 OSTHread 2424Scan Thread 11 OSTHread 15940:013> !gcroot 01d71798 Note: Roots found on stacks may be false positives. Run "!help gcroot" formore info.Scan Thread 0 OSTHread 1254Scan Thread 2 OSTHread 11f4Scan Thread 6 OSTHread 2380Scan Thread 7 OSTHread 1904Scan Thread 9 OSTHread 1130Scan Thread 10 OSTHread 221cScan Thread 12 OSTHread 2424Scan Thread 11 OSTHread 1594DOMAIN(004D4880):HANDLE(Pinned):3d112fc:Root:02d0a6c0(System.Object[])->01d71798(System.Runtime.Remoting.Channels.RegisteredChannelList)
0:013> !dumpdomain--------------------------------------System Domain: 6e4ce1f8LowFrequencyHeap: 6e4ce21cHighFrequencyHeap: 6e4ce268StubHeap: 6e4ce2b4Stage: OPENName: None--------------------------------------Shared Domain: 6e4cdb48LowFrequencyHeap: 6e4cdb6cHighFrequencyHeap: 6e4cdbb8StubHeap: 6e4cdc04Stage: OPENName: NoneAssembly: 0045f0a8--------------------------------------Domain 1: 0044a330LowFrequencyHeap: 0044a354HighFrequencyHeap: 0044a3a0StubHeap: 0044a3ecStage: OPENSecurityDescriptor: 0044b018Name: Server.exeAssembly: 0045f0a8 [C:\Windows\assembly\GAC_32\mscorlib\2.0.0.0__b77a5c561934e089\mscorlib.dll]ClassLoader: 0045f118SecurityDescriptor: 0045c3c0 Module Name6d481000 C:\Windows\assembly\GAC_32\mscorlib\2.0.0.0__b77a5c561934e089\mscorlib.dll001b2358 C:\Windows\assembly\GAC_32\mscorlib\2.0.0.0__b77a5c561934e089\sortkey.nlp001b2010 C:\Windows\assembly\GAC_32\mscorlib\2.0.0.0__b77a5c561934e089\sorttbls.nlp...--------------------------------------Domain 2: 004a4908LowFrequencyHeap: 004a492cHighFrequencyHeap: 004a4978StubHeap: 004a49c4Stage: OPENSecurityDescriptor: 00461e70Name: a52aab56-8c58-4b32-b298-d22914734328Assembly: 0045f0a8 [C:\Windows\assembly\GAC_32\mscorlib\2.0.0.0__b77a5c561934e089\mscorlib.dll]ClassLoader: 0045f118SecurityDescriptor: 004944b0 Module Name6d481000 C:\Windows\assembly\GAC_32\mscorlib\2.0.0.0__b77a5c561934e089\mscorlib.dll001b2358 C:\Windows\assembly\GAC_32\mscorlib\2.0.0.0__b77a5c561934e089\sortkey.nlp001b2010 C:\Windows\assembly\GAC_32\mscorlib\2.0.0.0__b77a5c561934e089\sorttbls.nlp...--------------------------------------Domain 3: 004bb1d0LowFrequencyHeap: 004bb1f4HighFrequencyHeap: 004bb240StubHeap: 004bb28cStage: OPENSecurityDescriptor: 00462130Name: 471b56c5-5b8c-44aa-a3e6-5d14fe3c4d91Assembly: 0045f0a8 [C:\Windows\assembly\GAC_32\mscorlib\2.0.0.0__b77a5c561934e089\mscorlib.dll]ClassLoader: 0045f118SecurityDescriptor: 004948f0 Module Name6d481000 C:\Windows\assembly\GAC_32\mscorlib\2.0.0.0__b77a5c561934e089\mscorlib.dll001b2358 C:\Windows\assembly\GAC_32\mscorlib\2.0.0.0__b77a5c561934e089\sortkey.nlp001b2010 C:\Windows\assembly\GAC_32\mscorlib\2.0.0.0__b77a5c561934e089\sorttbls.nlp...--------------------------------------Domain 4: 004c3d18LowFrequencyHeap: 004c3d3cHighFrequencyHeap: 004c3d88StubHeap: 004c3dd4Stage: OPENSecurityDescriptor: 004b70d0Name: 970ee547-afb3-491b-b159-359af030978aAssembly: 0045f0a8 [C:\Windows\assembly\GAC_32\mscorlib\2.0.0.0__b77a5c561934e089\mscorlib.dll]ClassLoader: 0045f118SecurityDescriptor: 00494b98 Module Name6d481000 C:\Windows\assembly\GAC_32\mscorlib\2.0.0.0__b77a5c561934e089\mscorlib.dll001b2358 C:\Windows\assembly\GAC_32\mscorlib\2.0.0.0__b77a5c561934e089\sortkey.nlp001b2010 C:\Windows\assembly\GAC_32\mscorlib\2.0.0.0__b77a5c561934e089\sorttbls.nlp...--------------------------------------Domain 5: 004d4880LowFrequencyHeap: 004d48a4HighFrequencyHeap: 004d48f0StubHeap: 004d493cStage: OPENSecurityDescriptor: 00461ec8Name: b343ebfd-7820-45c5-8a25-1fa0738d59bbAssembly: 0045f0a8 [C:\Windows\assembly\GAC_32\mscorlib\2.0.0.0__b77a5c561934e089\mscorlib.dll]ClassLoader: 0045f118SecurityDescriptor: 00494db8 Module Name6d481000 C:\Windows\assembly\GAC_32\mscorlib\2.0.0.0__b77a5c561934e089\mscorlib.dll001b2358 C:\Windows\assembly\GAC_32\mscorlib\2.0.0.0__b77a5c561934e089\sortkey.nlp001b2010 C:\Windows\assembly\GAC_32\mscorlib\2.0.0.0__b77a5c561934e089\sorttbls.nlp...
0:013> !do 01d30ffcName: System.Runtime.Remoting.Channels.RegisteredChannelListMethodTable: 6d6cc1bcEEClass: 6d4a2ee4Size: 12(0xc) bytes (C:\Windows\assembly\GAC_32\mscorlib\2.0.0.0__b77a5c561934e089\mscorlib.dll)Fields: MT Field Offset Type VT Attr Value Name6d6c4eec 4001f1d 4 System.Object[] 0 instance 01d30fd4 _channels0:013> !da 01d30fd4 Name: System.Runtime.Remoting.Channels.RegisteredChannel[]MethodTable: 6d6c4eecEEClass: 6d4aa8a0Size: 24(0x18) bytesArray: Rank 1, Number of elements 2, Type CLASSElement Methodtable: 6d6cc204[0] 01d30fec[1] 01d30ecc0:013> !do 01d30fecName: System.Runtime.Remoting.Channels.RegisteredChannelMethodTable: 6d6cc204EEClass: 6d507784Size: 16(0x10) bytes (C:\Windows\assembly\GAC_32\mscorlib\2.0.0.0__b77a5c561934e089\mscorlib.dll)Fields: MT Field Offset Type VT Attr Value Name6d6cc248 4001f1b 4 ...Channels.IChannel 0 instance 01d30f78 channel6d6eb3e0 4001f1c 8 System.Byte 1 instance 3 flags0:013> !do 01d30f78 Name: System.Runtime.Remoting.Channels.CrossAppDomainChannelMethodTable: 6d6cc0e4EEClass: 6d507720Size: 12(0xc) bytes (C:\Windows\assembly\GAC_32\mscorlib\2.0.0.0__b77a5c561934e089\mscorlib.dll)Fields: MT Field Offset Type VT Attr Value Name6d6e84dc 4001f7e 664 System.Object 0 shared static staticSyncObject >> Domain:Value 0044a330:01d30f84 004a4908:01d341cc 004bb1d0:01d4721c 004c3d18:01d4b4f4 004d4880:01d7171c <<6d6ea584 4001f7f 668 ...ity.PermissionSet 0 shared static s_fullTrust >> Domain:Value 0044a330:01d30f90 004a4908:01d341d8 004bb1d0:01d47228 004c3d18:01d4b500 004d4880:01d71728 <<0:013> !do 01d30eccName: System.Runtime.Remoting.Channels.RegisteredChannelMethodTable: 6d6cc204EEClass: 6d507784Size: 16(0x10) bytes (C:\Windows\assembly\GAC_32\mscorlib\2.0.0.0__b77a5c561934e089\mscorlib.dll)Fields: MT Field Offset Type VT Attr Value Name6d6cc248 4001f1b 4 ...Channels.IChannel 0 instance 01d19c9c channel6d6eb3e0 4001f1c 8 System.Byte 1 instance 3 flags0:013> !do 01d19c9c Name: System.Runtime.Remoting.Channels.Tcp.TcpChannelMethodTable: 61f476f4EEClass: 61eb5becSize: 24(0x18) bytes (C:\Windows\assembly\GAC_MSIL\System.Runtime.Remoting\2.0.0.0__b77a5c561934e089\System.Runtime.Remoting.dll)Fields: MT Field Offset Type VT Attr Value Name61f47794 4000160 4 ....TcpClientChannel 0 instance 01d19ccc _clientChannel61f4781c 4000161 8 ....TcpServerChannel 0 instance 01d19d04 _serverChannel6d6eab0c 4000162 10 System.Int32 1 instance 1 _channelPriority6d6e88c0 4000163 c System.String 0 instance 01d19cb4 _channelName0:013> !do 01d19d04 Name: System.Runtime.Remoting.Channels.Tcp.TcpServerChannelMethodTable: 61f4781cEEClass: 61eb5cb4Size: 68(0x44) bytes (C:\Windows\assembly\GAC_MSIL\System.Runtime.Remoting\2.0.0.0__b77a5c561934e089\System.Runtime.Remoting.dll)Fields: MT Field Offset Type VT Attr Value Name6d6eab0c 4000192 2c System.Int32 1 instance 1 _channelPriority6d6e88c0 4000193 4 System.String 0 instance 01d19cb4 _channelName6d6e88c0 4000194 8 System.String 0 instance 01d30900 _machineName6d6eab0c 4000195 30 System.Int32 1 instance 5555 _port6d6e73e4 4000196 c ....ChannelDataStore 0 instance 01d3092c _channelData6d6e88c0 4000197 10 System.String 0 instance 00000000 _forcedMachineName6d6eeadc 4000198 38 System.Boolean 1 instance 1 _bUseIpAddress6ce5e13c 4000199 14 System.Net.IPAddress 0 instance 01d2d9e4 _bindToAddr6d6eeadc 400019a 39 System.Boolean 1 instance 0 _bSuppressChannelData6d6eeadc 400019b 3a System.Boolean 1 instance 0 _impersonate6ce622b8 400019c 34 System.Int32 1 instance 2 _protectionLevel6d6eeadc 400019d 3b System.Boolean 1 instance 0 _secure6d6cfd5c 400019e 18 System.AsyncCallback 0 instance 01d30a78 _acceptSocketCallback61f45ac8 400019f 1c ...emotingConnection 0 instance 00000000 _authorizeRemotingConnection6d6eeadc 40001a0 3c System.Boolean 1 instance 0 authSet6d6e7434 40001a1 20 ...annelSinkProvider 0 instance 01d309c8 _sinkProvider61f478e0 40001a2 24 ...rverTransportSink 0 instance 01d30a68 _transportSink61f46478 40001a3 28 ...lusiveTcpListener 0 instance 01d30a98 _tcpListener6d6eeadc 40001a4 3d System.Boolean 1 instance 1 _bExclusiveAddressUse6d6eeadc 40001a5 3e System.Boolean 1 instance 1 _bListening
public IObj GetObj(string sName){ return m_ObjsAppDomain.CreateInstanceAndUnwrap(Assembly.GetExecutingAssembly().FullName, typeof(Obj).ToString()) as IObj;}
static void Main(){ TcpChannel tcpCh = new TcpChannel(Config.TcpPort); ChannelServices.RegisterChannel(tcpCh, false); ... }
static void Main(){ TcpChannel tcpCh = new TcpChannel(Config.TcpPort); ChannelServices.RegisterChannel(tcpCh, false); ...
}
Nota: la configurazione dichiarativa nei file di configurazione si applica solo al default AppDomain.
Nel seguito alcuni dei punti principali di questo post:
(tradotto e adattato da http://blogs.msdn.com/carlos/archive/2010/01/11/troubleshooting-a-remotingexception-by-dumping-out-remoting-channel-configuration.aspx)