Browse by Tags
All Tags »
Advices (
RSS)
A couple of days ago I hit a regression bug in .NET 3.5 SP1, in which when you have a generic class that implements ISerializable and has static variables – you can not serialize it using a BinaryFormatter without your application either hanging (x86) or raising an exception (x64 – a TargetInvocationException...
It’s been a few months since I started getting acquainted with the System.DateTimeOffset type and I can honestly say I don’t see any reason to use System.DateTime anymore. I’ve even gone as far as ask whether anyone knew when I would rather use DateTime over DateTimeOffset . The responses I got were...
After a couple of days of trying to run a load test for a web service on several agents via Visual Studio 2008, I come out much wiser and with a few new bald-spots, where hair I pulled out in the process used to be. I got a few errors whose messages have nothing to do with what really happened, so here's...
When using LINQ, queries may bloat up to dozens of lines. My personal style is to take these queries and break them apart to smaller units of logic. To each unit of logic, I append a call to ToArray . @yosit asked me why I did it and I answered I was avoiding a possible pitfall. Here's what I meant...
Tamir hates lambdas. He was having a problem with one of his lambda expressions and twittered about it. Around that time I opened my twitter account (yes, Yosi finally convinced me) and offered my help. He wanted to have a single extension method that could iterate over a collection and either change...
Got an exception being thrown with only its name being displayed in the output window? Want to catch that exception? Just click on Debug -> Exceptions (Ctrl D, E) and check the exception you want to catch whenever it's thrown: Now the debugger will catch any exception of that type, regardless...
I just finished a short conversation with Aaron Randall from London who used the little Windows Live Messenger Flash application in my sidebar (oh, how I love thee, Internets) to ask me a question he had about linked lists after reading one of my posts : "I am trying to understand the data structure...
DO NOT return null values from collection properties or from methods returning collections. Return an empty collection or an empty array instead. Users of collection properties often assume that the following code will always work: IEnumerable < string > list = GetList(); foreach ( string name...
A little known, as far as I can tell from asking around, yet extremely useful property in the Windows Forms designer's property grid is GenerateMember . Defaulting to true , it decides whether a control/component gets declared as a field on the form ( true ) or as a local variable in the InitializeComponent...
A colleague was baffled by having Control.Invoke (when called from a different thread) throw an ArgumentException at him and asked if I knew what was happening. Opening the stack trace, I found that the exception originated from Control.MarshaledInvoke : at System.Windows.Forms.Control.MarshaledInvoke...
The following code illustrates a great use for anonymous methods. public class MyContainerControl : Control { private class MySpecializedControl : Control { protected virtual void OnMyEvent(EventArgs e) { if ( this .MyEvent != null ) this .MyEvent( this , e); } public event EventHandler MyEvent; } private...
Since I've started working with CodePlex, Team System failed to even remember my username whenever I started Visual Studio. After digging a bit, I found the answer. Start the Stored User Names and Passwords control panel: rundll32 keymgr.dll,KRShowKeyMgr Add a new server (for CodePlex, it's tfs01.codeplex...