zoukankan      html  css  js  c++  java
  • 2010年07月 小记(telnet,xml命名空间,MaxItemsInObjectGraph, IIS传输限制, memcached Telnet Interface)

    1、在Windows 2008 R2下安装telnet客户端

    PS C:\Users\Administrator> servermanagercmd -install telnet-client

    2、使用XmlSerializer时移除xml声名和默认命名空间。

    代码
    protected string ToXml(object objectToConvert)
    {
    string str = null;

    using (MemoryStream stream = new MemoryStream())
    {
    //XmlWriterSettings.OmitXmlDeclaration移除xml声明
    using (XmlWriter xmlWriter = XmlTextWriter.Create(stream, 
                 new XmlWriterSettings() 
                { OmitXmlDeclaration = true, Encoding = Encoding.UTF8 }))
    {
    //移除命名空间
    XmlSerializerNamespaces ns = new XmlSerializerNamespaces();
    ns.Add(
    "", "");

    XmlSerializer serializer
    = new XmlSerializer(objectToConvert.GetType());
    serializer.Serialize(xmlWriter, objectToConvert, ns);

    byte[] buffer = new byte[stream.Length];
    stream.Position
    = 0;
    stream.Read(buffer,
    0, (int)stream.Length);

    str
    = Encoding.UTF8.GetString(buffer);
    xmlWriter.Close();
    }
    stream.Close();
    }

    if (str != null)
    {
    str
    = str.Trim();
    }

    return str;
    }

    3、WCF通信中如果出现序列化错误,如:

    "对象图中可以序列化或反序列化的项目数目上限为“65536”"

    请注意配置MaxItemsInObjectGraph。

    #通过代码配置:

               foreach (var op in client.Endpoint.Contract.Operations)
                {
                    var dataContractBehavior = op.Behaviors[typeof(DataContractSerializerOperationBehavior)]
                    as DataContractSerializerOperationBehavior;
     
                    if (dataContractBehavior != null)
                    {
                        dataContractBehavior.MaxItemsInObjectGraph = int.MaxValue;
                    }
                }
    

    #通过配置修改:

    <dataContractSerializer maxItemsInObjectGraph="2147483647" />

    4、IIS传输限制

    <httpRuntime maxRequestLength="20000" executionTimeout="600" />


    5、memcached Telnet Interface



  • 相关阅读:
    算法的时间复杂度
    二叉树递归建立和遍历
    数据挖掘之分类算法---knn算法(有matlab例子)
    C链表之创建简单静态链表
    ID3决策树算法原理及C++实现(其中代码转自别人的博客)
    adobe reader安装完成之前被中断,错误代码150210解决方法
    Oracle性能诊断艺术-读书笔记
    先对结果集排序然后做update、delete操作
    索引聚簇因子相关
    直方图及low_value、high_value
  • 原文地址:https://www.cnblogs.com/chenjunbiao/p/1772983.html
Copyright © 2011-2022 走看看