我爱我老婆

随笔分类 -  .Net Framework

摘要:如果有这个的xsd, group内嵌choice的结构: 使用svcutil 生成后的结果是:public class CreateType{ int NameID string Name}因为是choice 类型,这个结果显然不能表示choice的特点,bug?解决问题:生成前,使用xsl... 阅读全文
posted @ 2014-12-26 17:42 DataFlow 阅读(398) 评论(0) 推荐(0)
摘要:<client> <endpoint address="http://..." binding="basicHttpBinding" bindingConfiguration="..." contract="..." name="endpoint1" /></clent>之后, 当我们在程序里读取endpoint.Name时,却发现怎么也找不到endpoint1,会返回BindingName_ContractNamecode:public string get 阅读全文
posted @ 2013-02-17 15:57 DataFlow 阅读(1535) 评论(0) 推荐(0)
摘要:string replacement="$7777777777";Regex.Replace("hello","e",replacement);运行上面的一行,会报ArgumentException. 说捕获索引不能大于Int.MaxValue。程序的理解是,我的replacement string... 阅读全文
posted @ 2012-12-20 10:53 DataFlow 阅读(201) 评论(0) 推荐(0)
摘要:时间在XML可穿梭时,常用的格式有下面几种:yyyy-MM-ddTHH:mm:ss.fffffffzzzzzz (带时区偏移的时间格式, xml serilizer使用的格式)yyyy-MM-ddTHH:mm:ssZ (需要先转换成UTC time, Z表示这是一个UTC Time)o (需要先转换成UTC time, 推荐使用的方式)date.ToString("format", DateTimeFormatInfo.InvariantInfo); 阅读全文
posted @ 2012-08-29 10:15 DataFlow 阅读(550) 评论(0) 推荐(0)
摘要:我也是标题党,哈哈,是想谈一下在性能优化方面的经验 高内存占用: 之前有做过一个应用,内存动辄4G,做了两点改进后,内存占用缩小到10M 改动: 1. 检查所有非托管资源的使用,make sure 所有对象均正常调用 dispose 2. 检查所有大家伙(过长string, 和过长byte[]), 阅读全文
posted @ 2012-06-20 11:21 DataFlow 阅读(203) 评论(0) 推荐(0)
摘要:碰到Java序列化出来奇怪xml如:<User> <Friend>张三</Friend><Friend>张三</Friend> <Friend>张三</Friend></User>奇怪的是,Friend是一个数组,但并没有父元素,这种情况如果反序列化?[Serializable]public class User{ public Friend[]Friend { get; set; }}是不行的。正确方法:[Serializable]public class User { [XmlElement] 阅读全文
posted @ 2012-03-08 17:17 DataFlow 阅读(226) 评论(0) 推荐(0)
摘要:要控制HttpWebRequest在10秒内timeout, 设置两个属性即可,Timeout, ReadWriteTime但在异步模型中,.net framework却没有帮我们实现timeout.http://msdn.microsoft.com/en-us/library/system.net.httpwebrequest.begingetresponse.aspx如链接中所讲,In the case of asynchronous requests, it is the responsibility of the client application to implement its 阅读全文
posted @ 2012-02-21 18:02 DataFlow 阅读(2517) 评论(0) 推荐(0)
摘要:用HttpWebRequest去Call别的Service,怎样才能提高并发量和性能?因为建立一个TCP连接要三次握手,.Net 默认使用 keepAlive = Ture 去重用连接,避免重建Connection的开销,还有一些设置我们也要注意:DefaultConnectionLimitdescription: Maximum number of concurrent connections to a single ServicePointdefault: 2suggested: 12*N, N is the number of CPUMaxServicePointIdleTimedesc 阅读全文
posted @ 2012-02-01 15:23 DataFlow 阅读(877) 评论(0) 推荐(1)
摘要:既然有了xs:integer,为什么还要有xs:int?经过一番查找,真相浮出:xs:integer无小数的任意长度的整数, 如果要表示money, 或者会很大的数字,或者需要方便以后的扩展,这个会更合适xs:int无小数的32位长度的整数经过xsdGencode或者svcutil生成之后,使用xs:integer标识的属性将转为C#中的string类型使用xs:int标识的属性将转为int类型可能int类型会在性能上比string好些,于是有了下面的测试:1. 定义一个xsd, 分别使用30个xs:int/ xs:integer, 再转成DataContract2. 分别运行反序列化100W 阅读全文
posted @ 2012-01-29 10:18 DataFlow 阅读(1021) 评论(0) 推荐(0)
摘要:以下实现的目标是:localhost:6677/Services/Chinalocalhost:6677/Services/USAlocalhost:6677/Services/...以上所有调用都走到Service方法中,因为支持的国家是未知的,不能写成方法,并且请求的schame已经确定,不能再做修改,所以就有了以下实现:定义Service Interface,包含一个方法Service.代码 比较简单,只是重写OperationSelector属性,返回所有请求到方法"Service"(大小区分)public class RouteBehaviorExtension 阅读全文
posted @ 2011-12-31 16:52 DataFlow 阅读(448) 评论(0) 推荐(0)
摘要:在windows services开发中,碰到一个奇怪的问题:有时可以启动,有时启动超时,经过漫长的分析(有引用其它的组件),发现问题出在Performance counter的创建上,sometimes, the code will be hang here.Link:http://www.pcreview.co.uk/forums/strange-performance-counter-performance-problem-windows-service-application-t2781664.html解决方法:将Performance Counter操作放到OnStart方法中,不要 阅读全文
posted @ 2011-12-03 01:06 DataFlow 阅读(257) 评论(0) 推荐(0)
摘要:private void InternalWriteEvent(uint eventID, ushort category, EventLogEntryType type, string[] strings, byte[] rawData, string currentMachineName);Declaring Type:System.Diagnostics.EventLogInternalAssembly:System, Version=4.0.0.0private void InternalWriteEvent(uint eventID, ushort category, EventLo 阅读全文
posted @ 2011-12-02 16:22 DataFlow 阅读(261) 评论(0) 推荐(0)
摘要:User cache to hold connectionhttp://blogs.msdn.com/b/wenlong/archive/2007/10/27/performance-improvement-of-wcf-client-proxy-creation-and-best-practices.aspxno sleep of ThreadPoolhttp://blogs.msdn.com/b/wenlong/archive/2010/02/11/why-does-wcf-become-slow-after-being-idle-for-15-seconds.aspxhttp://msd 阅读全文
posted @ 2011-11-17 11:39 DataFlow 阅读(186) 评论(0) 推荐(0)
摘要:What's different:1. 数组不为空,但其中的元素均为空时:如Email[]; XmlSerializer:nothing. DataContractSerializer Datacontract出来的xml中没有Attribute, 像是为提高那10%的性能Datacontract ... 阅读全文
posted @ 2011-08-15 10:08 DataFlow 阅读(202) 评论(0) 推荐(0)
摘要:在DataContractSerializer之前有XMLSerializer, 网上关于此的比较有:http://www.danrigsby.com/blog/index.php/2008/03/07/xmlserializer-vs-datacontractserializer-serialization-in-wcf/亮点在此: 10%的性能提升.因为DataContractSerializer不支持一些xsd标签:group, all, choice...http://msdn.microsoft.com/zh-cn/library/ms733112.aspx如果要使用DataCont 阅读全文
posted @ 2011-07-21 14:38 DataFlow 阅读(409) 评论(0) 推荐(0)
摘要:取客户端的IP地址:var remote = System.ServiceModel.OperationContext.Current.IncomingMessageProperties[System.ServiceModel.Channels.RemoteEndpointMessageProperty.Name] as System.ServiceModel.Channels.RemoteEndpointMessageProperty;varip = remote.Address;取请求流长度:System.ServiceModel.Web.WebOperationContext.Curre 阅读全文
posted @ 2011-07-05 16:41 DataFlow 阅读(253) 评论(0) 推荐(0)
摘要:经过一个星期的准备,今天在公司内部讲了2个小时的.Net 框架,主要是面向C++开发人员,介绍了.Net的背景,发展,FCL, CLR, JIT, GC, Data Type, String, Array, Flow control, Exception handler, 有兴趣的可以下载,继续完善,让更多人更好地了解.Net下载地址:/Files/DataFlow/NET.ppt 阅读全文
posted @ 2011-02-24 18:00 DataFlow 阅读(270) 评论(0) 推荐(0)
摘要:ApplicationDomain也不一定,有时用exe有时用dll.一定的是,总是调用创建时间最新的那个,而忽略较早的那个。Don't care is exe or dll. 阅读全文
posted @ 2009-10-30 11:07 DataFlow 阅读(163) 评论(0) 推荐(0)
摘要:ADO.Net Entity Framework 阅读全文
posted @ 2009-10-23 12:06 DataFlow 阅读(205) 评论(0) 推荐(0)
摘要:1.要在Oninit中加载控件,因为在Oninit后,紧接着,在Load前,页面执行ViewState回填,会也用户输入的值回填到控件,也捎带上这个控件.protected override void OnInit(EventArgs e) { WebUserControl1 ucSampleRequestGridItem = (WebUserControl1)LoadControl("WebUs... 阅读全文
posted @ 2009-04-23 11:38 DataFlow 阅读(483) 评论(0) 推荐(0)