Fri
Oct 27
2006

Redirect Tracing to a File

<system.diagnostics> 
	<trace autoflush="true" indentsize="4"> 
			<listeners> n
			<add 	name="FileListener" 
				type="System.Diagnostics.TextWriterTraceListener" 
				initializeData="TraceLog2.txt" /> 
		</listeners> 
	</trace> 
</system.diagnostics>
Wed
Oct 25
2006

Detect Password Expiry

See the original Usenet posting.

public static DateTime PasswordExpirationDate(string user, string domain)
{
	string connect = String.Format("WinNT://{0}/{1},user", domain, user);
	DirectoryEntry entry = new DirectoryEntry(connect);
 
	if (entry == null)
		Console.WriteLine("Failed to get Directory Entry.");
 
	int secondsRemaining = (int)entry.Properties["MaxPasswordAge"][0];
 
	// A policy setting of -1 means no expiration,
	// so return an 'infinite' date
	if (secondsRemaining > 0) 
	{
		secondsRemaining -= (int)entry.Properties["PasswordAge"][0];
		return DateTime.Now.AddSeconds(secondsRemaining);
	} 
	else 
	{ 
		return DateTime.MaxValue; 
	}
}
Thu
Oct 19
2006

Hide property from the Visual Studio Designer

[Browsable(false), DesignerSerializationVisibility(
                            DesignerSerializationVisibility.Hidden)]
Tue
Oct 17
2006

Web Project Errors

When opening a web project:

The project you are trying to open is a Web project. You need to open it by specifying its URL path.

Create a file called c:\inetpub\wwwroot\Folder\MyProject.csproj.webinfo and add:

<VisualStudioUNCWeb>
    <Web URLPath = "http://localhost/Folder/MyProject.csproj" />
</VisualStudioUNCWeb>

More information

Sat
Oct 14
2006

Books to Check out

Agile Principles, Patterns and Practices in C# (Robert C Martin)
Applying UML and Patterns (Craig Larman)
The Pragmatic Programmer: From Journeyman to Master (Andrew Hunt, David Thomas)
Hibernate in Action (Bauer, King)
Effective Use of Microsoft Enterprise Library (Len Fenster)
- Books on effective unit testing
Refactoring (Martin Fowler)
The Humane Interface (Jef Raskin)

Sat
Oct 14
2006

.Net Articles

The Cost of GUIDs as Primary Keys
Creating and opening ASP.NET projects in Visual Studio .NET
VSS and Visual Studio .NET Information: Bindings, suo file, vss files explained.
Dispose, Finalization, and Resource Management

Thu
Oct 5
2006

Double.NaN Equality

Console.WriteLine(double.NaN.Equals(double.NaN)); // True
Console.WriteLine(double.NaN == double.NaN); // False

© 2009 Brian Low. All rights reserved.