.net

Why is .Equal False when i expect it to be true?

The first line is true, the second is false. htmlOut and s2 are StringWriter objects. bool b = s2.ToString() == htmlOut.ToString(); ret = htmlOut.Equals(s2); I expected true which b is but why is ret false? ...

Programmatically find out if system supports standby

This happens sometimes with Windows XP installations. Unless the display drivers are installed, power saving actions such as standby and hibernate are not supported. Whether the system supports hibernate can be checked - http://pinvoke.net/default.aspx/powrprof/IsPwrHibernateAllowed.html Is there something similar for checking standby ...

how to dump response headers in ASP.Net

Hello everyone, I am using VSTS 2008 + C# + .Net 3.5 to develop ASP.Net. I want to dump all response headers returned to client for a specific aspx file. Any ideas how to do this easily? I know how to use Response.Headers collection, but my confusion is where to enumerate to get the accurate response header? For example, if I enumerate...

How to release a managed resource which will not be garbage collected if the caller forget to use Dispose() ?

In my code, I have a class which create a new thread. This new thread has a Dispatcher, thus the thread will not finish unless I call Dispatcher.CurrentDispatcher.InvokeShutdown(); The thread cannot be referenced outside of my class. So I was thinking : how to ensure that my thread finish when my object is garbage collected ? One re...

any ideas to optimize the ASP.Net server load

Hello everyone, I am developing using VSTS 2008 + C# + .Net 3.5 to develop ASP.Net application. At client side, in order to keep session live, I will refresh server for every 5 seconds. Here is my code at client side, server side Default.aspx will do nothing -- for the only purpose to keep client alive. <html> <head> <meta http-equiv="...

Get types collection from EntityFramewrok ObjectContext

How can i extract list of Types from ObjectContext? e.g., i have object context contains entity named "Bank" and entity named "Company". I want to get the EntityObject type of them. How can i do this? ...

VS2003 Web Reference for a WCF Service has Extra "IdSpecified" Parameter

I am developing a WCF service using VSTS 2008 + .Net 3.5 + C# and it works fine when I also use VSTS 2008 to develop client (using Add Service Reference function to automatically generated client web services proxy code). The WCF I developed is using basicHttpBinding. The issue I met with is, when I use Visual Studio.Net (Visual Studio ...

CrystalReport Load report failed

I have a windows application project (C# and .NET 2.0) that used Crystal Report 2008. But I get error sometimes (it seems accidentally) in loading report. That error is: CrystalDecisions.Shared.CrystalReportsException: Load report failed. System.Runtime.InteropServices.COMException (0x8000020D): Unable to load report. at CrystalDec...

Which .Net library/project for facebook?

Which library/project is currently usable for creating Facebook applications? This is a followup to this question, where it seems like the projects mentioned in the original question have been abandoned. ...

PowerShell Runspace vs DLR

With the .NET 4.0 beta now available, and thus the wider availability of the .NET Dynamic Language Runtime, I guess these kinds of topics are going to become "hotter". I'm confused about the conceptual differences between the DLR and PowerShell. It seems to me that if I want to provide scripting capabilities in my .NET app, I can use...

Signing an assembly with Nant

How do I automatically add a strong name to a .NET assembly using a nant task? ...

User Web Chat, determine who is online, and targeting specific sessions?

First, I am using .net 3.5. I want to create an online chat system for my users. I have found some decent (open source) chat systems that I can use, but there are a couple features I want to add. I want the chat user to be able to see how many people are on their site and allow the chat user to select a user and begin to talk with them. ...

How to configure 2 applications with separate web.configs in a website?

Hi, I have 2 applications each one with a different web.config that I want to run in one website. which one of them will be configured as a virtual directory. I can't seem to get over the configuration inheritance issue. I have tried the location tag over the system.web and it doesn't work. or maybe I'm doing it wrong as I understand I'm...

Java's equivalents of Func and Action

What are Java's equivalents of Func and Action? I mean, instead of writing this on my own: public interface Func<TInput, TResult> { TResult call(TInput target) throws Exception; } public interface Action<T> { void call(T target) throws Exception; } ...

When to call WebResponse.Close()

WebResponse response; try { HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); request.Timeout = 20000; response = request.GetResponse(); request = (HttpWebRequest)WebRequest.Create(url2); response = request.GetResponse(); } catch(Exception ex) { //do something } finally { } where shou...

Html Parser & Object Model for .net/C#

Hi, I'm looking to parse html using .net for the purposes of testing or asserting its content. i.e. HtmlDocument doc = GetDocument("some html") List forms = doc.Forms() Link link = doc.GetLinkByText("New Customer") the idea is to allow people to write tests in c# similar to how they do in webrat (ruby). i.e. visits('\') fills_in "...

How to select text in a TextBox with the caret positioned at the START of the selection?

I'm using a System.Windows.Forms.TextBox. It is possible to select text by using the keyboard in such a way that the caret is positioned at the start of the selection - by holding Shift and moving the caret to the left. I would like to do the same programmatically. For example, suppose I have a text box with the text "Some sample text"...

What is the best way to empty a directory?

Is there a way to delete all files & sub-directories of a specified directory without iterating over them? The non elegant solution: public static void EmptyDirectory(string path) { if (Directory.Exists(path)) { // Delete all files foreach (var file in Directory.GetFiles(path)) { File.Delete(...

Can I programmatically view the managed heap contents from a .NET application?

Is it possible to access the managed heap in a .NET application and e.g. enumerate the objects that are currently allocated there? I know there are various tools out there that allow you to do that, but I would rather do this myself from code so that I can use it in automated tests, like for checking if everything is disposed and cleane...

Tips for VSTO Developers

I have a personal project that I'd like to build as an add-in for Microsoft Word 2007. I have prototyped it using VSTO with Visual Studio 2008 and found it surprisingly easy to work with the object model. I am however worried about deployment of my add-in. I assume users will need Office and .NET 3.5 (with SP1) installed, but will they...