草庐IT

connection-reset-by-peer

全部标签

c# - List<T>.Enumerator 的 Reset 方法的行为

以下两种方法(一种使用IEnumerator,另一种使用List.Enumerator)即使看起来相同会产生不同的结果。staticvoidM1(){varlist=newList(){1,2,3,4};IEnumeratoriterator=list.GetEnumerator();while(iterator.MoveNext()){Console.Write(iterator.Current);}iterator.Reset();while(iterator.MoveNext()){Console.Write(iterator.Current);}}staticvoidM2(){

c# - 防止 ORDER BY 子句中的 SQL 注入(inject)

在我们的数据库访问层中,我们有一些动态查询创建。例如,我们有以下方法来构建ORDERBY子句的一部分:protectedstringBuildSortString(stringsortColumn,stringsortDirection,stringdefaultColumn){if(String.IsNullOrEmpty(sortColumn)){returndefaultColumn;}returnString.Format("{0}{1}",sortColumn,sortDirection);}问题是,sortColumn和sortDirection都是来自外部的字符串,所以当

c# - GUID 是否及时订购?如果 ORDER BY 与 GUID 变量类型一起使用,最近创建的记录是否会延迟?

GUID是否及时订购?我的意思是,如果您将ORDERBY与GUID变量类型一起使用,最近创建的记录会延迟吗? 最佳答案 在Windows上,GUID(UUID)是使用UuidCreate从加密随机数生成器创建的。根据RFC4122,它们是版本4UUID。不涉及时间戳或以太网卡,除非您使用的是使用UuidCreateSequential创建的旧学校版本1GUID。另见HowRandomisSystem.Guid.NewGuid()?(Taketwo)来源:https://stackoverflow.com/a/3011149/1714

c# - connection.Close() 和 connection.Dispose() 有什么区别?

这个问题在这里已经有了答案:CloseandDispose-whichtocall?(8个答案)关闭9年前。我注意到System.Data.SQLite中的SQLiteConnection对象拥有两个相似的方法:关闭()Dispose()SQLiteDataReader对象也是如此。有什么区别?

c# - 尝试读取 xml 文件时的 ASP.Net, "An operation was attempted on a nonexistent network connection"

stringurl="http://www.example.com/feed.xml";varsettings=newXmlReaderSettings();settings.IgnoreComments=true;settings.IgnoreProcessingInstructions=true;settings.IgnoreWhitespace=true;settings.XmlResolver=null;settings.DtdProcessing=DtdProcessing.Parse;settings.CheckCharacters=false;varrequest=(Ht

c# - 如何在 Linq to SQL 中使用 distinct 和 group by

我正在尝试将以下sql转换为Linq2SQL:selectgroupId,count(distinct(userId))fromprocessroundissueinstancegroupbygroupId这是我的代码:varq=fromiinProcessRoundIssueInstancegroupibyi.GroupIDintogselectnew{Key=g.Key,Count=g.Select(x=>x.UserID).Distinct().Count()};当我运行代码时,我不断收到无效的GroupID。有任何想法吗?似乎distinct把事情搞砸了..这里是生成的sql:

c# - Tridion 2011 核心服务 : Unable to connect in a SSO environment

尝试连接到核心服务时出现以下错误:TheHTTPrequestwasforbiddenwithclientauthenticationscheme'Anonymous'Tridion环境配置了来自SiteMinder的SSO。这是我的代码:publicstaticICoreService2010GetTridionClient(){varbinding=newBasicHttpBinding(){Name="BasicHttpBinding_TridionCoreService",CloseTimeout=newTimeSpan(0,1,0),OpenTimeout=newTimeSp

c# - npgsql 泄漏 Postgres 数据库连接 : Way to monitor connections?

背景:我正在将我的应用程序从npgsqlv1迁移到npgsqlv2.0.9。运行我的应用程序几分钟后,我收到System.Exception:从池中获取连接时超时。网络声称这是由于连接泄漏(打开数据库连接,但没有正确关闭它们)造成的。所以我正在尝试诊断npgsql中泄漏的postgres连接。来自身边的各种网络文学;诊断泄漏连接的一种方法是在npgsql上设置日志记录,并在日志中查找泄漏连接警告消息。问题是,我在任何地方的日志中都没有看到这条消息。我还找到了监视npgsql连接的实用程序,但它不稳定并且会崩溃。所以我只能手动检查代码。对于创建npgsql连接的每个地方,都有一个fina

c# - 错误 : ExecuteReader requires an open and available Connection. 连接的当前状态为打开

我有下面带有DataHelperClass的mvc4网站来执行查询。我的问题有时是,网站以异常为标题。我使用block来处理SqlCommand和SqlDataAdapter但没有成功。请帮助我,对不起我的英语。try{if(_conn.State==ConnectionState.Closed)_conn.Open();using(SqlCommandsqlCommand=newSqlCommand(query,_conn)){sqlCommand.CommandType=CommandType.StoredProcedure;if(parameters!=null)sqlComma

c# - WCF,BasicHttpBinding : Stop new connections but allow existing connections to continue

.NET3.5、VS2008、使用BasicHttpBinding的WCF服务我在Windows服务中托管了一个WCF服务。当Windows服务关闭时,由于升级、定期维护等,我需要优雅地关闭我的WCF服务。WCF服务的方法最多可能需要几秒钟才能完成,典型的数量是每秒2-5次方法调用。我需要以允许任何先前调用方法完成的方式关闭WCF服务,同时拒绝任何新调用。通过这种方式,我可以在大约5-10秒内达到安静状态,然后完成Windows服务的关闭周期。调用ServiceHost.Close似乎是正确的方法,但它会立即关闭客户端连接,而无需等待任何正在进行的方法完成。我的WCF服务完成了它的方法