Category Archives: Platform

Deserializing to Dynamic with RestSharp

You can use JSON.NET to convert any RestSharp service response to a list of dynamic instances; you just need a bit of plumbing code to do it. Continue reading

Posted in Libraries, Silverlight, Web, Wndows Forms, WPF | Tagged , | 1 Comment

Writing Automated Performance Tests

I found a memory leak in my application, and wrote an automated test using GC.GetTotalMemory to tell if objects were leaking or not. They were (20MB of them in 100k instances). Continue reading

Posted in Core .NET, Silverlight, Wndows Forms, WPF | Tagged , | Leave a comment

DriveInfo: Total vs. Available Free Space

DriveInfo.AvailableFreeSpace gives you free space with quotas applied; on the other hand, TotalFreeSpace gives you the total, physical amount of empty space on the drive. Continue reading

Posted in Core .NET, Wndows Forms | Tagged | Leave a comment

Running Windows Services in Visual Studio

You can run a project that’s a Windows service with an infinite loop (yes, really) by invoking the service and waiting. Forever. You can do this conditionally (while not debugging), instead of running ServiceBase.Run. Continue reading

Posted in Core .NET, Wndows Forms | Tagged | Leave a comment

Using Enumerations as Bit Flags

You can use enumerations as bit flags. The FlagsAttribute is optional; more importantly, you need to assign powers of 2^n to the enum’s values. Depending on the .NET version, checking can be easy (.HasFlag) or hard (bitwise AND operation) Continue reading

Posted in Core .NET, Silverlight, Web, Wndows Forms, WPF | Tagged , | Leave a comment

Creating an Instance Without Using Constructors

You can create an instance of a class without calling any of its contructors, via a call to System.Runtime.Serialization.FormatterServices.GetUninitializedObject(typeof(A)). Scary, but useful in certain cases (like creating instances of highly-coupled or hard-to-instantiate classes in tests). Continue reading

Posted in Core .NET, Web, Wndows Forms | Tagged | Leave a comment

Simple Strategies to Boost SQL Server Performance

SQL Server can be a beast on your disk. Two easy ways to help raise performance for high-volume databases: Use a drive other than the Windows partition for the SQL Server DB files, and split the MDF and LDF files onto different drives if possible. Continue reading

Posted in Platform, Tools, Topic, Web | Tagged , | Leave a comment

Storing a String List in App.Config or Web.Config

How can you store a list of strings (or ints, say) into a single appSetting key/value pair? Surprisingly, it’s as easy as using a delimited list (like comma-delimited or semicolon-delimited) and splitting it at runtime. Continue reading

Posted in Core .NET, Silverlight, Web, Wndows Forms, WPF | Tagged , | Leave a comment

Procedure Expects Parameter Which Was Not Supplied

SqlCommand’s Parameters prevent SQL injection attacks. Surprisingly, when passed in a null value, you get the exception: Procedure or function “…” expects parameter ‘@foo’, which was not supplied. Continue reading

Posted in Core .NET, Web, Wndows Forms, WPF | Tagged , , | Leave a comment

Updated Version of Random Number Generators

After several months, I’ve finally updated the normally-distributed random number generator to tolerate negative numbers in its range. Thanks to everybody who complained to get this feature done! Continue reading

Posted in Libraries, Silverlight, Web, Wndows Forms | Tagged | Leave a comment