草庐IT

application-close

全部标签

c# - XmlWriter : is calling Close() required if using a using block?

使用usingblock(不调用Close())创建XmlWriter是否足够,还是使用try/finallyblock并在finally中调用Close()更好? 最佳答案 usingblock是try/finallyblock的快捷方式,它在任何实现IDisposable的对象上调用Dispose()。对于流和流编写器,Dispose()通常手动调用Close()。使用反射器,这里是XmlWriter的Dispose方法:protectedvirtualvoidDispose(booldisposing){if(this.Wri

c# - 哪些场景会触发 Application_End 事件?

Asp.net有一个Application_End事件,它在应用程序结束时发生,如下所示voidApplication_End(objectsender,EventArgse){}我的问题如下:这个事件是什么时候真正发生的,即什么样的情况会触发它?假设我有一个运行24x7x365的银行Web应用程序,它连续执行并一次从数千个地方访问,那么这个Application_End事件会在什么时候发生?什么样的情况会导致这种情况? 最佳答案 Application_End事件在IIS池被回收或当您更改bin文件夹或web.config文件时被

c# - httpWebRequest(底层连接已关闭 : The connection was closed unexpectedly. )

我正在开发一个C#应用程序,它记录来自网络服务器的数据。它向网络服务器发送以下发布请求并等待响应。//////FunctionforobtainingtestCgidata/////////privatestringHttpmyPost(stringParameters){stringstr="Noresponse";HttpWebRequestrequest=(HttpWebRequest)WebRequest.Create(uriTestCGI);request.Method="POST";byte[]bytes=Encoding.UTF8.GetBytes(Parameters)

c# - ClickOnce 应用程序错误 : Deployment and application do not have matching security zones

我在IE中使用FireFox和Chrome的ClickOnce应用程序时遇到问题,它工作正常。异常的详细信息是:PLATFORMVERSIONINFOWindows:6.1.7600.0(Win32NT)CommonLanguageRuntime:4.0.30319.239System.Deployment.dll:4.0.30319.1(RTMRel.030319-0100)clr.dll:4.0.30319.239(RTMGDR.030319-2300)dfdll.dll:4.0.30319.1(RTMRel.030319-0100)dfshim.dll:4.0.31106.0(M

c# - 设计 : How to inform controllers about data modification across application

在基于mvc的大型系统中,有负责编辑数据的View和显示该数据的View。示例:UserManagementView和UserSelectionView.每个子系统都应该知道自己是否需要更新数据,在另一个子系统对相同数据进行更改后,以便其Controller知道是否需要更新数据。我对此的想法有点像观察者模式(有点集成在c#中),所有Controller都将成为监听器,并最终会收到发生数据操纵的通知。BindingList例如提供ListChanged事件。同样,可以为每个数据结构创建一个接口(interface),并将更改通知Controller。这会增加开销(IMO),而且我发现这种

c# - 响应消息的内容类型 application/xml;charset=utf-8 与绑定(bind)的内容类型不匹配 (text/xml; charset=utf-8)

我尝试使用独立应用程序使用WCFWeb服务。我可以使用InternetExplorer查看此服务,也可以在VisualStudio服务引用中查看。这是我遇到的错误Thecontenttypetext/html;charset=UTF-8oftheresponsemessagedoesnotmatchthecontenttypeofthebinding(text/xml;charset=utf-8).如何更改它以使用正确的内容类型?这是我的配置文件这是堆栈{System.ServiceModel.ProtocolException:Thecontenttypeapplication/xm

c# - 诊断 ObjectDisposedException "Safe handle has been closed"

我有一个C#应用程序,它正在使用消息命中ObjectDisposedExceptionSafehandlehasbeenclosed我一启动应用程序就会发生这种情况。遗憾的是,堆栈跟踪确实没有帮助(见下文)。我有什么办法可以确定这里正在异步尝试调用什么?DoAsyncCall()真的意味着异步方法调用吗?mscorlib.dll!System.Threading.EventWaitHandle.Set()+0xebytesmscorlib.dll!System.Runtime.Remoting.Messaging.AsyncResult.SyncProcessMessage(Syste

c# - 将 VB 转换为 C# - My.Application.Info.DirectoryPath

以下VB(VB.NET、VisualBasic)语句的最佳C#(csharp)等价物是什么:My.Application.Info.DirectoryPathMy.Computer.ClipboardMy.Computer.Audio.PlaySystemSound()My.Application.Shutdown() 最佳答案 应用程序.ExecutablePath系统.Windows.Forms.剪贴板系统.媒体.*应用程序.退出 关于c#-将VB转换为C#-My.Applicati

C# 系统.Net.WebException : The underlying connection was closed: An unexpected error occurred on a send

我在一台运行WindowsServer2003的服务器上遇到此错误:System.Net.WebException:Theunderlyingconnectionwasclosed:Anunexpectederroroccurredonasend.这是我的代码...有什么想法吗?HttpWebRequestrequest=(HttpWebRequest)WebRequest.Create("https://URLHERE");//request.Headers.Add("Accept","application/xml");byte[]bytes;bytes=System.Text.E

c# - 系统.ServiceModel.CommunicationException : The underlying connection was closed

我正在从一个wcf网络服务中检索数据,当数据超过20万条记录时,我得到一个异常,如下所示:System.ServiceModel.CommunicationException:Theunderlyingconnectionwasclosed:Aconnectionthatwasexpectedtobekeptalivewasclosedbytheserver.--->System.Net.WebException:Theunderlyingconnectionwasclosed:Aconnectionthatwasexpectedtobekeptalivewasclosedbythes