Exemplo n.º 1
0
        /// <summary>
        /// To avoid a problem inside MS code that can happen once per 380 thousand requests on multiCPU machines.
        /// </summary>
        static GenuineUniversalServerTransportSink()
        {
            // remove the damned pool
            BinaryServerFormatterSinkProvider binaryServerFormatterSinkProvider = new BinaryServerFormatterSinkProvider();
            Type coreChannelType     = binaryServerFormatterSinkProvider.GetType().Assembly.GetType("System.Runtime.Remoting.Channels.CoreChannel");
            Type byteBufferAllocator = binaryServerFormatterSinkProvider.GetType().Assembly.GetType("System.IO.ByteBufferAllocator");

            FieldInfo       _bufferPool     = coreChannelType.GetField("_bufferPool", BindingFlags.NonPublic | BindingFlags.Static);
            ConstructorInfo constructorInfo = byteBufferAllocator.GetConstructor(new Type[] { typeof(Int32) });

            _bufferPool.SetValue(null, constructorInfo.Invoke(new object[] { 0x1000 }));
        }
Exemplo n.º 2
0
        /// <summary>
        ///  Create a TcpChannel with a given name, on a given port.
        /// </summary>
        /// <param name="port"></param>
        /// <param name="name"></param>
        /// <returns></returns>
        private static TcpChannel CreateTcpChannel(string name, int port, int limit)
        {
            ListDictionary props = new ListDictionary();

            props.Add("port", port);
            props.Add("name", name);
            props.Add("bindTo", "127.0.0.1");

            BinaryServerFormatterSinkProvider serverProvider =
                new BinaryServerFormatterSinkProvider();

            // NOTE: TypeFilterLevel and "clientConnectionLimit" property don't exist in .NET 1.0.
            Type typeFilterLevelType = typeof(object).Assembly.GetType("System.Runtime.Serialization.Formatters.TypeFilterLevel");

            if (typeFilterLevelType != null)
            {
                PropertyInfo typeFilterLevelProperty = serverProvider.GetType().GetProperty("TypeFilterLevel");
                object       typeFilterLevel         = Enum.Parse(typeFilterLevelType, "Full");
                typeFilterLevelProperty.SetValue(serverProvider, typeFilterLevel, null);

//                props.Add("clientConnectionLimit", limit);
            }

            BinaryClientFormatterSinkProvider clientProvider =
                new BinaryClientFormatterSinkProvider();

            return(new TcpChannel(props, clientProvider, serverProvider));
        }
Exemplo n.º 3
0
        public static TcpChannel GetTcpChannel(IDictionary properties)
        {
            BinaryServerFormatterSinkProvider serverProvider =
                new BinaryServerFormatterSinkProvider();

            // NOTE: The TypeFilterLevel enum/propety doesn't exist in .NET 1.0.
            Type typeFilterLevelType = typeof(object).Assembly.GetType("System.Runtime.Serialization.Formatters.TypeFilterLevel");

            if (typeFilterLevelType != null)
            {
                PropertyInfo typeFilterLevelProperty = serverProvider.GetType().GetProperty("TypeFilterLevel");
                object       typeFilterLevel         = Enum.Parse(typeFilterLevelType, "Full");
                typeFilterLevelProperty.SetValue(serverProvider, typeFilterLevel, null);
            }

            BinaryClientFormatterSinkProvider clientProvider =
                new BinaryClientFormatterSinkProvider();

            return(new TcpChannel(properties, clientProvider, serverProvider));
        }