草庐IT

connection-handling

全部标签

c# - Visual Studio : edit-and-continue on handled exceptions?

这是重现我期望得到的行为的代码:staticvoidMain(string[]args){//try//#2{stringx=null;//#1AssertNotNull(x,nameof(x));}//catch(ArgumentNullException){}//#2Console.WriteLine("Passed.");Console.ReadKey();}[DebuggerHidden]publicstaticvoidAssertNotNull(Targ,stringargName)whereT:class{if(arg==null)thrownewArgumentNullE

c# - 为什么 e.Handled = true 不起作用?

我有以下XAML在后面的代码中我正在这样做privatevoidStackPanel_MouseEnter(objectsender,MouseEventArgse){}privatevoidGrid_MouseEnter(objectsender,MouseEventArgse){e.Handled=true;}privatevoidButton_MouseEnter(objectsender,MouseEventArgse){e.Handled=true;}现在,即使我将鼠标移到Button上并设置e.Handled=true,Grid和StackPanel分别被调用。为什么?我应

c# - 打开SqlConnection "Handle is invalid"错误

此错误已开始偶尔且莫名其妙地发生,尤其是在连接到我们的session状态数据库时。这是错误:Exceptiontype:COMExceptionExceptionmessage:Thehandleisinvalid.(ExceptionfromHRESULT:0x80070006(E_HANDLE))atSystem.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32errorCode,IntPtrerrorInfo)atSystem.Data.ProviderBase.DbConnectionPool.T

c# - 无效操作异常 : No IAuthenticationSignInHandler is configured to handle sign in for the scheme: MyCookieAuthenticationScheme

我正在尝试按照说明进行操作here将Cookie身份验证添加到我的网站。到目前为止,我添加了以下内容:InvoketheUseAuthenticationmethodintheConfiguremethodoftheStartup.csfile:app.UseAuthentication();InvoketheAddAuthenticationandAddCookiemethodsintheConfigureServicesmethodoftheStartup.csfile:services.AddAuthentication("MyCookieAuthenticationScheme

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# - 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服务完成了它的方法