@@ -36,23 +36,27 @@ static void Main(string[] args)
36
36
{
37
37
try
38
38
{
39
- RemotingConfiguration . CustomErrorsMode = CustomErrorsModes . Off ;
40
39
bool secure = false ;
41
- int port = 12345 ;
40
+ int port = 12345 ;
42
41
string ipc = String . Empty ;
43
42
bool showhelp = false ;
44
43
TypeFilterLevel typefilter = TypeFilterLevel . Low ;
44
+ CustomErrorsModes custom_errors = CustomErrorsModes . Off ;
45
+ string name = "RemotingServer" ;
45
46
46
- OptionSet p = new OptionSet ( ) {
47
- { "s|secure" , "Enable secure mode" , v => secure = v != null } ,
48
- { "p|port=" , "Specify the local TCP port to listen on" , v => port = int . Parse ( v ) } ,
49
- { "t|typefilter=" , "Specify the type filter level (low,full), default low" ,
50
- v => typefilter = ( TypeFilterLevel ) Enum . Parse ( typeof ( TypeFilterLevel ) , v , true ) } ,
51
- { "i|ipc=" , "Specify listening pipe name for IPC channel" , v => ipc = v } ,
52
- { "h|?|help" , v => showhelp = v != null } ,
47
+ OptionSet p = new OptionSet ( ) {
48
+ { "s|secure" , "Enable secure mode" , v => secure = v != null } ,
49
+ { "p|port=" , "Specify the local TCP port to listen on" , v => port = int . Parse ( v ) } ,
50
+ { "t|typefilter=" , "Specify the type filter level (low,full), default low" ,
51
+ v => typefilter = ( TypeFilterLevel ) Enum . Parse ( typeof ( TypeFilterLevel ) , v , true ) } ,
52
+ { "i|ipc=" , "Specify listening pipe name for IPC channel" , v => ipc = v } ,
53
+ { "e|error=" , "Set custom error mode (On, Off, RemoteOnly) (don't show full errors in remote calls)" ,
54
+ v => custom_errors = ( CustomErrorsModes ) Enum . Parse ( typeof ( CustomErrorsModes ) , v , true ) } ,
55
+ { "n|name=" , "Set the remoting class name" , v => name = v } ,
56
+ { "h|?|help" , v => showhelp = v != null } ,
53
57
} ;
54
-
55
- p . Parse ( args ) ;
58
+
59
+ p . Parse ( args ) ;
56
60
57
61
if ( showhelp )
58
62
{
@@ -62,6 +66,8 @@ static void Main(string[] args)
62
66
}
63
67
else
64
68
{
69
+ RemotingConfiguration . CustomErrorsMode = custom_errors ;
70
+
65
71
Trace . Listeners . Add ( new ConsoleTraceListener ( true ) ) ;
66
72
67
73
IChannel chan ;
@@ -70,7 +76,7 @@ static void Main(string[] args)
70
76
BinaryServerFormatterSinkProvider serverSinkProvider = new BinaryServerFormatterSinkProvider ( ) ;
71
77
serverSinkProvider . TypeFilterLevel = typefilter ;
72
78
73
- if ( ! String . IsNullOrEmpty ( ipc ) )
79
+ if ( ! string . IsNullOrEmpty ( ipc ) )
74
80
{
75
81
properties [ "portName" ] = ipc ;
76
82
properties [ "authorizedGroup" ] = "Everyone" ;
@@ -87,13 +93,12 @@ static void Main(string[] args)
87
93
88
94
RemotingConfiguration . RegisterWellKnownServiceType (
89
95
typeof ( RemoteType ) ,
90
- "RemotingServer" ,
96
+ name ,
91
97
WellKnownObjectMode . Singleton ) ;
92
98
93
99
bool isipc = chan is IpcChannel ;
94
100
95
- Console . WriteLine ( "Server Activated at {0}://{1}/RemotingServer" , isipc ? "ipc" : "tcp" , isipc ? ipc : "HOST:" + port . ToString ( ) ) ;
96
-
101
+ Console . WriteLine ( "Server Activated at {0}://{1}/{2}" , isipc ? "ipc" : "tcp" , isipc ? ipc : "HOST:" + port . ToString ( ) , name ) ;
97
102
Console . ReadLine ( ) ;
98
103
}
99
104
}
0 commit comments