.net

Are SOLID principles really solid?

The first pattern stands for this acronym is SRP. Here is a quote. the single responsibility principle states that every object should have a single responsibility, and that responsibility should be entirely encapsulated by the class. That's is simple and clear till we start to code ) Suppose we have a class with well def...

Does the .Net Framework Contain any Libraries for Monitoring Network Activity?

I'd like to experiment with writing my own little monitoring/firewall app. ...

Extending EF4 SQL Generation

Hi, We're using EF4 in a fairly large system and occasionally run into problems due to EF4 being unable to convert certain expressions into SQL. At present, we either need to do some fancy footwork (DB/Code) or just accept the performance hit and allow the query to be executed in-memory. Needless to say neither of these is ideal and th...

Is there any easy way to hide the radio buttons, checkboxes, etc. without hiding the content?

I'm suspecting the answer is no, but I just want confirmation before I move on - is there any easy way (as in, not re-templating) to hide things like the box that gets checked on a CheckBox, the drop-down arrow of a combo box, etc. without hiding the actual content being displayed? ...

KeyValuePair<TKey, TValue> - member fields question

In looking at the source for the KeyValuePair<TKey, TValue> struct, the private member fields are only ever written to by the constructor. Is there a design consideration of some sort as to why these are not marked readonly? ...

Generating Color Gradient

I want to display to my user how many (percent wise) of their forms are compliant with the new standard. The way I want to let them know visually is the percent amount will be colored. It will be 0xFF0000 (pure red) for 0% and 0x00FF00 (pure green) at 100%. What is the best way to calculate the color for each step along the way? ...

Linq Queries converting to lambda expressions ?

Hello from item in range where item % 2 ==0 select i ; is converting to lamda expressions as below range.where(item % 2 ==0).select(x=>x). I feel that first way of linq is translating next one and if it is ,so is there any optimization like this range.where(item & 2 == 0) instead of other one ? ...

C# - Downside to Setting Initial Value in Declaration

Is there any downside to a class like: class Example1 { protected string UserId = (string)Session["user"]; } //versus class Example2 { protected string UserId; public Example2() { UserId = (string)Session["user"]; } } If I always want to set this value is there any downside to Example1? UPDATE: Session["user"] is se...

ASPX Load controls from SQLDataSources CONCURRENTLY

I have many controls on my aspx page (DropDownLists) each bound to a SQLDataSource. They stored proc takes a long time to run. I have been working with the DBAs for weeks to try to speed them up. We got it down to about 1-2 seconds for the slowest ones. However loading eight of these one a page is too long for a user to wait! So, I wou...

Exists a replacement for the command-line-tool CASPOL.exe?

When trying to execute a .NET-App, it throws a "PolicyException", because "only one group is allowed". The tool should list existing settings, and allow to delete selected settings. Using caspol to list is not helpful, it is cruel. I've seen there is a simple gui-frontend, which allows to define NEW settings, but it does not allow to li...

Forms authentication for classic ASP on IIS 7.0

Hello, I am trying to integrate ASP.NET Security with Classic ASP. Like in next article - http://weblogs.asp.net/scottgu/archive/2007/03/04/tip-trick-integrating-asp-net-security-with-classic-asp-and-non-asp-net-urls.aspx, but I have IIS 7.0 instead of IIS 6.0 as in example. You can find my configuration file below (after adding of wil...

Problem with XElement and XslCompiledTransform

I'm having some trouble using a combination of XElement and XslCompiledTransform. I've put the sample code I'm using below. If I get my input XML using the GetXmlDocumentXml() method, it works fine. If I use the GetXElementXml() method instead, I get an InvalidOperationException when calling the Transform method of XslComiledTransform: ...

What happens to an IDisposable object after I return it?

I have a C# function that flips the orientation of a DataSet: static DataSet FlipDataSet(DataSet my_DataSet) { using (DataSet ds = new DataSet()) { foreach (DataTable dt in my_DataSet.Tables) { DataTable table = new DataTable(); for (int i = 0; i <= dt.Rows.Coun...

.Net regex: what is the word character \w?

Simple question: What is the pattern for the word character \w in c#, .net? My first thought was that it matches [A-Za-z0-9_] and the documentation tells me: Character class Description Pattern Matches \w Matches any \w "I", "D", "A", "1", "3" word character. ...

Distinguishing between .NET exception types

For the love of all things holy, how do you distinguish between different "exception flavors" within the predefined .NET exception classes? For example, a piece of code might throw an XmlException under the following conditions: The root element of the document is NULL Invalid chars are in the document The document is too long All o...

What did I do wrong here when trying to unit test a class that references a web service

So I had a class that referenced a class that referenced another class that called a web service. So I learn how to create an interface using partial classes. I inject the web service through the constructor. Then my unit test fails because I am newing up the actual web service in the second level of the class. So I end up modifying ...

Unity and web service

I had this awesome idea... but I am afraid maybe it is actually a bad idea.... we use unity for dependency injection. I make interfaces from my web services using partial classes for the purpose of mocking and web services.... What I want to do is put my web services into unity and get them via dependency injection... What do you thi...

What happens if an asynchronous delegate call never returns?

I found a decent looking example of how to call a delegate asynchronously with a timeout... http://www.eggheadcafe.com/tutorials/aspnet/847c94bf-4b8d-4a66-9ae5-5b61f049019f/basics-make-any-method-c.aspx. In summary it uses WaitOne with a timeout to determine if the call does not return before the timeout expires. I also know that you s...

How can I remove all users in an Active Directory group?

I'm trying to remove all users from an AD group with the following code: private void RemoveStudents() { foreach (DirectoryEntry childDir in rootRefreshDir.Children) { DirectoryEntry groupDE = new DirectoryEntry(childDir.Path); for (int counter = 0; counter < groupDE.Properties["member"].Count; counter++...

Publishing WCF .NET 3.5 to IIS 6 (Windows Server 2003)

I've been developing a WCF web service using .NET 3.5 with IIS7 and it works perfectly on my local computer. I tried publishing it to a server running IIS 6 and even though I can view the WSDL in my browser, the client application doesn't seem to be connecting to it correctly. I launched a packet sniffing app (Charles Proxy) and the resp...