public static void RegisterRemotingChannel () { if (!channelRegistered) { channelRegistered = true; IDictionary formatterProps = new Hashtable (); formatterProps ["includeVersions"] = false; formatterProps ["strictBinding"] = false; // Don't reuse ipc channels registered by add-ins. That's not supported. IChannel ch = ChannelServices.GetChannel ("ipc"); if (ch != null) { LoggingService.LogFatalError ("IPC channel already registered. An add-in may have registered it"); throw new InvalidOperationException ("IPC channel already registered. An add-in may have registered it."); } BinaryServerFormatterSinkProvider serverProvider = new BinaryServerFormatterSinkProvider(formatterProps, null); serverProvider.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full; DisposerFormatterSinkProvider clientProvider = new DisposerFormatterSinkProvider(); clientProvider.Next = new BinaryClientFormatterSinkProvider(formatterProps, null); unixRemotingFile = Path.GetTempFileName (); IDictionary dict = new Hashtable (); dict ["portName"] = Path.GetFileName (unixRemotingFile); ChannelServices.RegisterChannel (new IpcChannel (dict, clientProvider, serverProvider), false); // Register the TCP channel too. It is used for communication of Mono -> .NET. The IPC channel // has interoperabilitu issues. // Don't reuse tcp channels registered by add-ins. That's not supported. ch = ChannelServices.GetChannel ("tcp"); if (ch != null) { LoggingService.LogFatalError ("TCP channel already registered. An add-in may have registered it"); throw new InvalidOperationException ("TCP channel already registered. An add-in may have registered it."); } serverProvider = new BinaryServerFormatterSinkProvider(formatterProps, null); serverProvider.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full; clientProvider = new DisposerFormatterSinkProvider(); clientProvider.Next = new BinaryClientFormatterSinkProvider(formatterProps, null); dict = new Hashtable (); dict ["port"] = 0; ChannelServices.RegisterChannel (new TcpChannel (dict, clientProvider, serverProvider), false); // This is a workaround to a serialization interoperability issue between Mono and .NET // For some reason, .NET is unable to resolve add-in assemblies referenced in // serialized objects, when the assemblies are not in the main bin directory if (PropertyService.IsWindows) { AppDomain.CurrentDomain.AssemblyResolve += delegate (object s, ResolveEventArgs args) { if (!simpleResolveAssemblies.Contains (args.Name)) return null; foreach (Assembly am in AppDomain.CurrentDomain.GetAssemblies ()) { if (am.GetName ().FullName == args.Name || args.Name == am.GetName ().Name) { Console.WriteLine (Environment.StackTrace); return am; } } return null; }; } } }
static RemotingService () { clientProvider = new DisposerFormatterSinkProvider(); clientProvider.Next = new BinaryClientFormatterSinkProvider(); }
public static void RegisterRemotingChannel() { if (!channelRegistered) { channelRegistered = true; IDictionary formatterProps = new Hashtable(); formatterProps ["includeVersions"] = false; formatterProps ["strictBinding"] = false; // Don't reuse ipc channels registered by add-ins. That's not supported. IChannel ch = ChannelServices.GetChannel("ipc"); if (ch != null) { LoggingService.LogFatalError("IPC channel already registered. An add-in may have registered it"); throw new InvalidOperationException("IPC channel already registered. An add-in may have registered it."); } BinaryServerFormatterSinkProvider serverProvider = new BinaryServerFormatterSinkProvider(formatterProps, null); serverProvider.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full; DisposerFormatterSinkProvider clientProvider = new DisposerFormatterSinkProvider(); clientProvider.Next = new BinaryClientFormatterSinkProvider(formatterProps, null); unixRemotingFile = Path.GetTempFileName(); IDictionary dict = new Hashtable(); dict ["portName"] = Path.GetFileName(unixRemotingFile); ChannelServices.RegisterChannel(new IpcChannel(dict, clientProvider, serverProvider), false); // Register the TCP channel too. It is used for communication of Mono -> .NET. The IPC channel // has interoperabilitu issues. // Don't reuse tcp channels registered by add-ins. That's not supported. ch = ChannelServices.GetChannel("tcp"); if (ch != null) { LoggingService.LogFatalError("TCP channel already registered. An add-in may have registered it"); throw new InvalidOperationException("TCP channel already registered. An add-in may have registered it."); } serverProvider = new BinaryServerFormatterSinkProvider(formatterProps, null); serverProvider.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full; clientProvider = new DisposerFormatterSinkProvider(); clientProvider.Next = new BinaryClientFormatterSinkProvider(formatterProps, null); dict = new Hashtable(); dict ["port"] = 0; dict ["rejectRemoteRequests"] = true; ChannelServices.RegisterChannel(new TcpChannel(dict, clientProvider, serverProvider), false); // This is a workaround to a serialization interoperability issue between Mono and .NET // For some reason, .NET is unable to resolve add-in assemblies referenced in // serialized objects, when the assemblies are not in the main bin directory if (Platform.IsWindows) { AppDomain.CurrentDomain.AssemblyResolve += delegate(object s, ResolveEventArgs args) { if (!simpleResolveAssemblies.Contains(args.Name)) { return(null); } foreach (Assembly am in AppDomain.CurrentDomain.GetAssemblies()) { if (am.GetName().FullName == args.Name || args.Name == am.GetName().Name) { Console.WriteLine(Environment.StackTrace); return(am); } } return(null); }; } } }
static RemotingService() { clientProvider = new DisposerFormatterSinkProvider(); clientProvider.Next = new BinaryClientFormatterSinkProvider(); }