.NET: SqlDataReader.Close or .Dispose results in Timeout Expired exception

When trying to call Close or Dispose on an SqlDataReader i get a timeout expired exception. If you have a DbConnection to SQL Server, you can reproduce it yourself with: String CRLF = "rn"; String sql = "SELECT * " + CRLF + "FROM (" + CRLF + " SELECT (a.Number * 256) + b.Number AS Number" + CRLF + " FROM master..spt_values a," + CRLF + " master..spt_values b" +

.NET:SqlDataReader.Close或.Dispose结果在Timeout Expired异常中

当试图在SqlDataReader上调用Close或Dispose时,我得到一个超时过期异常。 如果你有一个到SQL Server的DbConnection,你可以用下面的方法自己重新创建它: String CRLF = "rn"; String sql = "SELECT * " + CRLF + "FROM (" + CRLF + " SELECT (a.Number * 256) + b.Number AS Number" + CRLF + " FROM master..spt_values a," + CRLF + " master..spt_values b" + CRLF + " WHERE a

Instantly detect client disconnection from server socket

How can I detect that a client has disconnected from my server? I have the following code in my AcceptCallBack method static Socket handler = null; public static void AcceptCallback(IAsyncResult ar) { //Accept incoming connection Socket listener = (Socket)ar.AsyncState; handler = listener.EndAccept(ar); } I need to find a way to discover as soon as possible that the client has disconnec

立即检测客户端与服务器套接字的连接

如何检测客户端与我的服务器断开连接? 我在我的AcceptCallBack方法中有以下代码 static Socket handler = null; public static void AcceptCallback(IAsyncResult ar) { //Accept incoming connection Socket listener = (Socket)ar.AsyncState; handler = listener.EndAccept(ar); } 我需要找到一种方法来尽快发现客户端与handler Socket断开连接。 我试过了: handler.Available; handler.Send(new byte[1], 0

Wpf UserControl and MVVM

I am thinking about writing a WPF User Control for my application. I am using MVVM in my application. User control's may require Dependency Properties that can be set my Parent View. when using MVVM, the idea is that the Parent View will eventually create a binding between the UserControls DP with Parent View's VM) Dependency Properties need to be created in the View class as VM do

Wpf UserControl和MVVM

我正在考虑为我的应用程序编写一个WPF用户控件。 我在我的应用程序中使用MVVM。 用户控件可能需要可以设置我的父视图的依赖项属性。 当使用MVVM时,其想法是父视图最终将在UserControls DP与父视图的VM之间创建一个绑定) 由于VM不从DependencyObject继承,所以需要在View类中创建Dependency Properties 。 这意味着在后面的XAML代码中添加代码。 我想知道是否可以提供有关如何在使用MVVM开发WPF应用程序时设计用户控件

Making sure OnPropertyChanged() is called on UI thread in MVVM WPF app

In a WPF app that I'm writing using the MVVM pattern, I have a background process that doing it's thing, but need to get status updates from it out to the UI. I'm using the MVVM pattern, so my ViewModel knows virtually nothing of the view (UI) that is presenting the model to the user. Say I have the following method in my ViewModel: public void backgroundWorker_ReportProgress(obj

确保在MVVM WPF应用程序中的UI线程上调用OnPropertyChanged()

在我使用MVVM模式编写的WPF应用程序中,我有一个后台进程来完成这件事,但需要从UI中获取状态更新。 我使用MVVM模式,所以我的ViewModel几乎不知道向用户展示模型的视图(UI)。 假设我在ViewModel中有以下方法: public void backgroundWorker_ReportProgress(object sender, ReportProgressArgs e) { this.Messages.Add(e.Message); OnPropertyChanged("Messages"); } 在我看来,我有一个ListBox绑定到ViewModel

Is MVVM pointless?

Is orthodox MVVM implementation pointless? I am creating a new application and I considered Windows Forms and WPF. I chose WPF because it's future-proof and offer lots of flexibility. There is less code and easier to make significant changes to your UI using XAML. Since the choice for WPF is obvious, I figured that I may as well go all the way by using MVVM as my application architecture

MVVM毫无意义?

正统的MVVM实现是没有意义的吗? 我正在创建一个新的应用程序,我认为Windows窗体和WPF。 我选择WPF是因为它具有面向未来的功能并提供了很大的灵活性。 代码更少,使用XAML可以更轻松地对UI进行重大更改。 由于WPF的选择是显而易见的,我认为我可以通过使用MVVM作为我的应用程序体系结构,因为它提供了可混合性,分离问题和单元可测试性。 理论上,它看起来很像UI编程的圣杯。 这个简短的冒险; 然而,变成了一个真正的头

Cannot open Word document after publishing (Office.Interop.Word)

I cannot open Word document in c# after publishing to IIS It can open Word document and replace any text in debug mode by using Microsoft.Interop.Office.Word. When I publish the project, it return the following error: object reference not set to an instance of an object Here is my code: try { Microsoft.Office.Interop.Word.Application wordApp = new Microsoft.Office.Interop.Word.Applicat

发布后无法打开Word文档(Office.Interop.Word)

发布到IIS后,我无法在c#中打开Word文档 它可以通过使用Microsoft.Interop.Office.Word打开Word文档并以调试模式替换任何文本。 当我发布该项目时,它会返回以下错误: 你调用的对象是空的 这是我的代码: 尝试{ Microsoft.Office.Interop.Word.Application wordApp = new Microsoft.Office.Interop.Word.Application {Visible = true}; Microsoft.Office.Interop.Word.Document doc = wordApp.Documents.Open(re

How can I force a hard refresh (ctrl+F5)?

We are actively developing a website using .Net and MVC and our testers are having fits trying to get the latest stuff to test. Every time we modify the style sheet or external javascript files, testers need to do a hard refresh (ctrl+F5 in IE) in order to see the latest stuff. Is it possible for me to force their browsers to get the latest version of these files instead of them relying on the

我如何强制刷新(ctrl + F5)?

我们正在积极开发一个使用.Net和MVC的网站,我们的测试人员正试图获得最新的测试内容。 每次我们修改样式表或外部JavaScript文件时,测试人员都需要进行硬刷新(在IE中按Ctrl + F5)才能看到最新的东西。 我有可能强迫他们的浏览器获取这些文件的最新版本,而不是依赖于它们的缓存版本吗? 我们没有从IIS或任何其他方面进行任何特殊的缓存。 一旦投入生产,很难告诉客户他们需要硬刷新才能看到最新的变化。 谢谢! 您

How can I get my webapp's base URL in ASP.NET MVC?

How can I quickly determine what the root URL is for my ASP.NET MVC application? Ie, if IIS is set to serve my application at http://example.com/foo/bar, then I'd like to be able to get that URL in a reliable way that doesn't involve getting the current URL from the request and chopping it up in some fragile way that breaks if I re-route my action. The reason that I need the base URL i

如何在ASP.NET MVC中获取我的webapp的基本URL?

我如何快速确定我的ASP.NET MVC应用程序的根URL是什么? 也就是说,如果IIS设置为在http://example.com/foo/bar上为我的应用程序提供服务,那么我希望能够以可靠的方式获取该URL,而不涉及从当前URL请求并以某种脆弱的方式将其切碎,如果我重新布置我的动作,就会中断。 我需要基本URL的原因是,此Web应用程序调用另一个需要根用于调用者Web应用程序的回调用途。 假设你有一个Request对象可用,你可以使用: string.Format(

WebService memory usage when hosted in CassiniDev after rebuild

I have got a WCF service which takes up quote some memory, around 1GB. Its hosted locally in development asp.net hosting (CassiniDev). When I make a change in code and hit build, server doesn't stop working. It actually starts to use updated code seamlessly, except for memory. From what it appears it just doubles memory usage after rebuild, so I am not quite sure whats going on here.

重建后托管在CassiniDev中的WebService内存使用情况

我有一个WCF服务,占用大约1GB的内存。 它在本地托管在开发asp.net(CassiniDev)中。 当我在代码中进行更改并点击构建时,服务器不会停止工作。 它实际上开始无缝地使用更新的代码,除了内存。 从它看起来它只是在重建后使内存使用率翻倍,所以我不太确定这里发生了什么。 我的机器上的内存很少,所以有时会导致整个系统冻结。 我想知道为什么一旦它开始更新dll就不会运行一些GC收集,例如,导致内存大小增加一倍。de

Service has zero application (non

I recently created a WCF service (dll) and a service host (exe). I know my WCF service is working correctly since I am able to successfully add the service to WcfTestClient. However, I seem to be running into an issue when I comes to utlizing my WCF from a service host (exe). I can add a reference to the WCF (dll) to my service host (exe) and create the necessary componets to the exe; such a

服务没有应用程序(非

我最近创建了一个WCF服务(dll)和一个服务主机(exe)。 我知道我的WCF服务工作正常,因为我能够成功地将服务添加到WcfTestClient。 但是,当我从服务主机(exe)中使用我的WCF时,我似乎遇到了一个问题。 我可以将WCF(dll)的引用添加到我的服务主机(exe)中,并为exe创建必要的组件; 如服务安装程序,服务主机和app.config,编译并使用InstallUtil最终安装该exe文件。 但是,当我尝试在Microsoft管理控制台中启动该服