Software Development Blog
A place for me to put reminders, tips, tricks and 'gotchas' about software development.
Subject tags used in these blob posts:
Azure • Binding • Blazor • C++ • C# • CORS • Cosmos DB • CRC • EF6 • Excel
FNV • Guid • Hash • Installer • Mathematica
Maths • MD5 • NuGet • Random • Security
Silverlight • SQLite • Visual Studio • Web API • WinForms • WPF • Xamarin • Xoro
25 February 2025 | Technology Idiocy Log | |
In my previous post about easing into retirement, I mentioned many examples of random idiotic wildly counterproductive things keep going wrong and suck all enjoyment of working in IT. Idiotic things are still happening, and this post is a growing log of recent idiotic problems related to IT and technology in general that I can show to friends and colleagues as proof of how "everything f***ing doesn't work". | ![]() |
|
14 January 2025 | Easing into retirement | |
Hello everyone, I have an announcement and tale that might interest you. I’m easing into retirement. Companies I’ve been working for are being sold, retired or are no longer developing new software. I only have a few hours of ad-hoc maintenance work each week. Running out of legacy work would drive a regular dev to seek new work, but in my case, I declined to create a LinkedIn page, or send out feelers through contacts for new work, because… I’m burnt out. | ![]() |
|
11 January 2025 | Web API Status Codes and Errors | Web API |
This post is an update to one I made in 2018 which complained about the clumsy way REST style web services use status codes to report success or failure for various types of requests. The key point I'm going to make is that the convention of using status codes like 201 (Created), 204 (NoContent), 400 (BadRequest), etc, is inappropriate for expressing the results from a typical business service. | ![]() |
|
05 April 2024 | ParallelForAsync alternatives | C# |
The Parallel.For and similar methods available in .NET Framework 4.0+ and .NET Standard 2.0+ are designed to simplify parallelism of CPU intensive processing. The Task and related classes (released a bit sooner) when combined with the async and await C# keywords facilitate simple coding patterns for fine-grained concurrency. |
![]() |
|
16 February 2024 | DateTime Ticks Breakdown | Maths |
For more than 20 years I've been looking at DateTime.Ticks Int64 values and they always look like 63nnnnnnnnnnnnnnnn, and I was wondering how long I have to wait until the leading digits become 64. |
![]() |
|
07 December 2023 | Visual Studio conditional compile any file contents | |
The MSBuild tools and Visual Studio provide a variety of techniques for conditionally compiling source code based upon the active configuration. The #if preprocessor directives allow lines of code to included or excluded based upon defined symbols. The Condition element in project files allows whole files to be included or excluded from the build. | ![]() |
|
13 October 2023 | Custom build properties and items | |
Microsoft msbuild processing provides a convenient way of factoring out common build properties that might be shared by many projects. I read about this feature years ago, then forgot about it, so I'm posting this as a reminder to myself and any other developers who might be interested. |
![]() |
|
19 August 2023 | Enumerate Azure Storage Accounts (New) | Azure |
In April 2021 I posted an article titled Enumerate Azure Storage Accounts which explained how to enumerate all of the storage accounts in an Azure subscription, then drill down into all the containers and blobs, and tables and rows. This sort of code can be used as the basis of some useful custom reporting tools. |
![]() |
|
16 August 2023 | Azure Table 'batch' (transaction) operations | Azure |
To bulk insert rows in the old Azure Table Storage API you would create a TableBatchOperation class and fill it with TableOperations, then call ExecuteBatchAsync. The batch could contain different operations, but bulk inserts were my most common need. |
![]() |
|
03 February 2023 | localhost has been blocked by CORS policy | Blazor • CORS • Security • Web API |
For many years I could not debug a Web API service and Blazor app on localhost. I would debug-run the service in
one instance of Visual Studio 2022 and the Blazor app in another instance.
The first client call to the service would return:
Access to fetch at 'http://localhost:5086/endpoint' from origin 'http://localhost:56709' has been blocked by CORS policy:
Response to preflight request doesn't pass access control check: [cut]
|
![]() |
|
21 November 2022 | The Stupid Random Number Generator | Maths • Random • Web API |
Inspired by Donald Knuth's 1959 "Super-random" number generator that didn't work (see Page 5), I created my own generator which I think does work, but only by brute force and theft of other algorithms (it also has poor performance). |
![]() |
|
18 October 2022 | CRC vs Hash Algorithms | CRC • FNV • Hash • MD5 |
Before the System.IO.Hashing namespace was introduced in late 2021, the .NET FCL (Framework Class Library) did not provide any classes for error detection or hashing. | ![]() |
|
25 August 2022 | PRNG Relative Performance | Guid • Random • Xoro |
I was wondering about the relative speed of different Pseudo-Random Number Generator (PRNG) algorithms. I wrote a DOS command with methods annotated by BenchmarkDotNet attributes and gave it a run. This chart shows the relative speed of the algorithms running in a tight loop to generate 500K Int32 values. | ![]() |
|
24 July 2022 | Phone number as sum of powers | Mathematica • Maths • Random |
One of Dave Plummer's videos titled Top 50 Worst Computer Dialogs skims through a selection of different hilariously absurd and impractical web controls for picking dates, phone numbers, audio volume, etc. | ||
17 July 2022 | WinForms RadioButton Binding | Binding • WinForms |
Last week I had to write demo program using Windows Forms, which was a mind-trip into the past because I migrated to using WPF for all desktop apps since 2010. As an academic exercise I tried to use data binding of the UI controls to properties of a controller class. For me, Windows Forms binding works acceptably well, but it has never felt like a first-class citizen in comparison to WPF where it's deeply integrated into the framework. |
![]() |
|
15 June 2022 | C++ Stupidity and Delusion | C++ |
I recently returned to writing C++ after a 17-year gap and I have concluded that C++ has become the stupidest language in contemporary common use and fans of the language are living in some form of mass delusional insanity. Upon returning to C++ after a long absence, I am shocked and angered by what I have found. |
![]() |
|
29 May 2022 | NuGet include native DLL | C++ • C# • NuGet |
I had to create a NuGet package which included a native DLL written in C++. Utility functions in the native DLL are called from C# using standard Interop techniques. The projects consuming the package may be either the traditional Framework format or the newer Sdk format. The vital requirement is that the native DLL is copied to the build output folder in the same way as managed DLLs. | ![]() |
|
08 May 2022 | Because it is being used by another process | |
I wanted to scan the contents of log files, but many of them failed to open because of: The process cannot access the file 'filename' because it is being used by another process. | ![]() |
|
30 April 2022 | Entity Framework 6 and HierarchyId | EF6 |
If you create an Entity Framework 6 EDMX (data model) which contains tables with columns of type hierarchyid then you will get some warnings and the table will arrive in the designer with the offending columns removed. However, you can define and process those types of columns in a strongly-typed manner. | ![]() |
|
21 April 2022 | Visual Studio 2022 target 4.5 | Visual Studio |
My laptop which has only had Visual Studio 2022 installed and has no history of any other versions being installed will not load projects targeting .NET Framework 4.5. It suggests a download, but no suitable files are available from the Microsoft download pages any more. | ![]() |
|
30 March 2022 | Set specific directory access controls | Security |
I had to create a directory with was only accessible to a specific Windows account and no other accounts, not even Administrators or SYSTEM. This was needed to isolate the important directory and its files from accidental (or malicious) access by any process other than the single service that used them. | ![]() |
|
12 March 2022 | Silverlight death and funeral | Silverlight |
The light that burns twice as bright burns half as long - and you have burned so very, very brightly, Silverlight. With apologies to Blade Runner, I feel the quote is appropriate. Silverlight version 2 to 5 lived from 2007 to 2012 when Microsoft very quietly announced that development had ceased and end-of-life was scheduled for October 2021. That's a very short lifetime, even when measured in software platform years. | ![]() |
|
04 December 2021 | Miscellaneous Gotchas | C# • Web API |
A mixture of strange problems that took some effort to solve: CreateBitmapSourceFromHBitmap, 500.35 ANCM Multiple In-Process Applications, C# record serialization, Cosmos DB Linq crash, Swagger and minimal APIs, etc. | ![]() |
|
29 November 2021 | C# Compiler Source Generators | C# |
The following discussion of Roslyn Code Generators is out-of-date now that the Roslyn SDK has been expanded with a recommendation to use the Incremental Generator API. For an update see my blog post Technology Idiocy Log. | ![]() |
|
22 November 2021 | Count Lines of Code | |
If you have written any utility which counts lines of code, then throw it away because I accidentally discovered someone has done the job ... properly! I've deleted my old scripts because they were really tricky to write and the numbers they produced could only be regarded as approximations. Parsing arbitrary file contents accurately is inherently difficult and I'm glad someone with more patience, expertise and time has done the job for me. | ![]() |
|
27 September 2021 | Cosmos DB Request Unit Logging | Cosmos DB |
This post replaces an earlier one titled Catch Cosmos Client statistics where I briefly explained how you can use a request handler to intercept statistics about each database query. The statistics include the Request Units (RUs) expended by each query, which is correlated to the actual cost of running the database. | ![]() |
|
12 September 2021 | Cosmos DB Client V3 | Cosmos DB |
The latest Cosmos DB V3 client library makes coding easier for .NET developers. The class model is simpler and more sensible, and the LINQ extensions let you write concise and type-safe queries. | ![]() |
|
06 September 2021 | Catch Cosmos Client statistics | Cosmos DB |
Skip this article and read the more detailed replacement above titled Cosmos DB Request Unit Logging. | ![]() |
|
02 September 2021 | Web API arbitrary response data | Web API |
This is about .NET Framework, not .NET Core — A couple of times a year I have to return a Web API response with a specific status code and serialized object in the body. Sounds easy, but every time this happens I spend 30-60 minutes searching until my fingers bleed for the simplest answer. | ![]() |
|
25 August 2021 | SDK Project attributes | Visual Studio |
The newer SDK-style project files (*.csproj) do not support all of the Assembly attributes that could be used in older project files. A simple example is the AssemblyTrademarkAttribute. There is no <Trademark> element defined in the new projects. Arbitrary attributes can however be added like this sample: | ![]() |
|
04 August 2021 | Delete Azure Tenant | Azure |
Some time over the previous few years ago I was playing with the Azure B2C feature and I accidentally created two extra Tenants under my Azure Subscription. When I signed-in to my Visual Studio subscription I could see 3 tenants listed in various menus and lists. I made occasional passing attempts to delete the irritating extra Tenants... |
![]() |
|
17 April 2021 | BigInteger Factoring | Maths |
On a recent Sunday afternoon I was writing some code snippets in LINQPad to play with Fermat's Little Theorem and Carmichael Numbers. As part of the experiment I wrote a simple method to factor integers, just using trial division up to the square root. Although it wasn't completely dumb trial division... | ![]() |
|
11 April 2021 | Enumerate Azure Storage Accounts | Azure |
This article uses deprecated classes and libraries. For a modern code sample see: Enumerate Azure Storage Accounts (New). |
![]() |
|
27 March 2021 | Blazor ignore rewrite rule | Blazor |
The root folder of a Blazor app contains a Web.config file with the following rewrite rule to send all requests into the Webassembly runtime... | ![]() |
|
24 February 2021 | Generating Excel documents in C# | C# • Excel |
From a .NET project I needed to generate an Excel document containing a single sheet containing titles, numbers and dates with simple but pleasant formatting. I found there are two ways of doing this without using 3rd party products. | ![]() |
|
21 February 2021 | SQLite rehabilitated | EF6 • SQLite |
About 10 years ago I attempted to use SQLite in some projects, but getting it integrated and working nicely in a .NET project was a fragile and frustrating process. I remember a cavalcade of compile and runtime errors caused by 32/64 bit confusion and making bad choices due to scatter-brained documentation. As an experiment this weekend I tried to process one of my old SQLite databases in a modern .NET Core project via Entity Framework... | ![]() |
|
28 November 2020 | Blazor Webassembly notes | Blazor |
I believe that Blazor Webassembly apps are now the only sensible way for .NET developers to write web applications. My recent experience with the officially released Blazor Webassembly platform confirms that it is the most productive way of writing apps to run in the web browser. I estimate I can write a typical business app in Blazor about 10 times faster that an equivalent server-side ASP.NET app, and it probably takes about one tenth the amount of code. A similar app created with a JS framework like Angular would require millions of lines... | ![]() |
|
20 October 2020 | Regasm in setup project | Installer |
This post is a reminder to myself (and anyone) about how to register a COM visible .NET assembly in a Visual Studio Setup Project (vdproj). Countless pages describe how to register traditional COM server libraries, but it took hours to stumble upon a tiny clue that lead me to the code below that can be placed in a CA (Custom Action) class to register a COM visible assembly. | ![]() |
|
26 March 2020 | Visual Studio document delete lines containing | Visual Studio |
Often when I'm editing a text file in the Visual Studio document editor, I want to delete all lines containing a certain string of text. I always assumed this required some bothersome technique like writing macros or extensions, so for a decade or more I just dismissed it as too hard. |
![]() |
|
28 January 2020 | Parsing a VDPROJ file | Installer |
While writing a small utility to scan and summarise Visual Studio project files of type vcproj and vdproj I was reminded that the vdproj file is not XML, it's a custom format that's a little bit like JSON. A quick search revealed that there is no standard library to parse vdproj files, and I saw lots of ugly suggestions as workarounds. It turns out you can convert a vdproj file into an XElement with about 50 lines of quite straightforward code... | ![]() |
|
28 September 2019 | Memorable Computer Generated Keys | Security |
Computer systems often publish information for humans to read: invoices, sales dockets, memberships, subscriptions, travel bookings, etc. Items like these are expected to have some sort of unique 'key' associated with them, so for example, if you phone an airline to change a flight they will ask "what is your booking number?", then your correct reply allows immediate verification and you can proceed. | ![]() |
|
20 September 2019 | Installer Customer Information Dialog | Installer |
When creating an MSI installer using a Visual Studio Setup Project you may want the user to enter their company name and a serial number as some sort of anti-piracy measure. Installers for many commercial products use this technique and it would nice if a similar step could be inserted in the wizard sequence in a Setup Project with minimal effort. |
![]() |
|
22 May 2019 | Guid constant bits | Guid • Hash • Security |
People often casually say that the .NET Framework Guid contains 128 pseudo-random bits. This is not technically correct however, as we should know that at least one of the 4-bit nibbles is always the value 4, reducing the random bit count to 124. I suspected other bits were fixed values as well, but didn't know which ones. So I used LINQPad to generate hundreds of Guids and dump the bit counts and see which ones really have fixed values. | ![]() |
|
02 April 2019 | Windows update error 0x80248007 | |
With increasing frequency over the last year I stumble over the problem where a Windows 10 machine will fail to install updates with error 0x80248007. Once this happens you're "stuck" and updates will fail forever more. This seems to only happen when major Windows 10 operating system updates are involved. Extensive web searches produce conflicting and dangerous advice about how to overcome this problem... | ![]() |
|
01 April 2019 | VMware Workstation and Device/Credential Guard are not compatible | |
Each year or so, or after a big Windows update I can't launch VMWare Workstation due to the error in this post's title. And each time this happens I can't remember what I did last time to fix it, so I run some searches and find dozens of variations of ridiculously complicated answers that I remember DO NOT work. Changing Device Guard policy seemed sensible but it didn't work for me. Just run this command as admin... | ![]() |
|
05 January 2019 | UDP Broadcasting Sample | |
Every year or so I have to use the UdpClient class to perform simple broadcasting and receiving, and I forgot how to do it. There are lots of combinations of parameters that don't work or produce unhelpful crashes if you get them wrong. | ![]() |
|
28 February 2018 | I'm in the future of the web and it doesn't work | |
I have seen the future and it works -- Lincoln Steffens (1931) I have seen the future and it doesn't work -- Zardoz (1974) We are well into the 21st century now, and "the web" is broken, it's sick, and all the endless band aids and stitches being applied to it to keep it alive and keep it working are actually suffocating and killing it. |
![]() |
|
24 January 2018 | Collections Database History | |
a.k.a. Thinking outside the relational database box — Like most software developers, I have "pet projects" that are used to try new technologies and platforms while performing some useful utility function for work or leisure. I have one such project that has been running for 36 years ... and it's finally practically finished! | ![]() |
|
30 August 2017 | Visual Studio 2017 Web Debug Start Page | Visual Studio |
After upgrading to Visual Studio 2017 I found that the start page of ASP.NET projects would popup the message like the following... | ![]() |
|
22 August 2017 | log4net UDP Listener | |
There are lots of articles online about how to write a UDP listener client for logging broadcasts from the log4net UdpAppender. Unfortunately, most of them use localhost, or hard-coded addresses and port numbers and are misleadingly trivial and not good guidance for realistic use. | ![]() |
|
30 July 2017 | windbg SOS CLR | |
This post is a reminder to myself, and I hope it will help others. About once a year I find a .NET program will run fine in development but crash and vanish when deployed to production with the generic message "this program has stopped working". | ![]() |
|
17 July 2017 | Windows 10 Open command window here | |
NOTE (Sep 2019) - Some recent Windows update has broken the following instructions. The registry change no longer returns the missing context menu. If anyone knows of a simple low-risk fresh workaround, please let me know. | ![]() |
|
17 July 2017 | Set Windows Service Description | Installer |
This is a quick follow-up to the previous post about creating MSI installers for Windows Services. To change a service description (not the name or display name), you have to call into native functions in advapi32.dll which contains... | ![]() |
|
09 July 2017 | Visual Studio MSI Service Installer | Installer |
The "standard" Visual Studio way of creating a Windows Service when a product is installed is to create a Custom Action class derived from Installer which uses the ServiceInstaller and ServiceProcessInstaller classes to register the service. There are plenty of samples of this technique around. | ![]() |
|
05 July 2017 | log4net string pattern | |
After a few years I had to define some log4net appenders in config files and I couldn't remember how to substitute runtime values into the appender parameters. A classic need was to change the address of the mail server for an SmtpAppender. I spent about 30 minutes searching for an answer and came across all sorts of stupid or outdated suggestions that required tedious coding. I knew there was an easy way, but it was so easy I couldn't remember it! | ![]() |
|
28 May 2017 | String to multi-lines of max length | |
Every couple of years I have to split a long string of text into multiple lines of a maximum length. In the latest example I wanted to display long paragraphs of /? help text in a command line utility where each line must be 79 characters maximum length. | ![]() |
|
19 May 2017 | Wiki Articles | |
I have some obsolete Wiki pages that are of technical and historical interest. It's too hard to migrate the articles over here into the blog, so here are some links to them instead... | ![]() |
|
09 April 2017 | Xamarin and Azure Storage | Azure • Xamarin |
June 2022 — This article is probably irrelevant because the Xamarin development platform has changed significantly since this article was published. Portable Class Libraries (PCLs) are deprecated, Xamarin has changed and NuGet packages and dependencies have changed. The Xamarin platform has been deprecated and replaced with MAUI. The following post remains here only for historical interest. | ![]() |
|
29 March 2017 | Xamarin Forms Observations | Xamarin |
Early 2022 note: The Xamarin platform has improved a lot since this article was written. Overall stability has greatly improved, there is a richer set of controls and libraries, and the UI design experience can be regarded as acceptable. More importantly though, Xamarin has evolved into the MAUI platform, so this article will soon become a historical curiosity. | ![]() |
|
03 March 2017 | Registration of the app failed | |
After a few weeks I returned to a Windows Universal app in Visual Studio and hit F5 to run and debug it. It said:
Registration of the app failed. Another user has already installed an unpackaged version of this app. |
![]() |
|
04 February 2017 | TaskDialog (Windows API Code Pack) | |
August 2024 Note: The following old article is well out-of-date now. From .NET 5+ you can use the TaskDialog class which is
provided in the System.Windows.Forms namespace and library, and it exposes more options than the other free libraries.
|
![]() |
|
29 November 2016 | SourceTree Authenticate prompt | |
September 2021 note: SourceTree is a clumsy bug-ridden mess that has only marginally been improved in the four years since I made this post. The great news is that you can uninstall and delete SourceTree from your mind because Visual Studio now has all the Git source control functionality you need integrated into it. | ![]() |
|
19 November 2016 | SQLite and Dapper ORM | SQLite |
This morning I tried to read a SQLite database for the first time in at least 3 years. I remember the last time I tried to integrate SQLite into a C# project with Entity Framework 6 and designer support I just about went mad. It took hours and hours of searching and bumbling around to eventually get the right combination of references and config values. | ![]() |
|
31 October 2016 | Wordpress install on Windows | |
WordPress claims to have the famous 5-minute installation, but where is it? Attempting to install WordPress in IIS on a modern Windows server is a ridiculously confusing process for the uninitiated. If you go to wordpress.com you're invited to create an account and a hosted site... | ![]() |
|
06 July 2016 | Windows Universal String.GetHashCode | Hash |
Since late 2021 you can use the |
![]() |
|
23 June 2016 | Parsing Color strings | |
This is a reminder to myself about how to parse strings like "MistyRose" and "#ffe4e1" into a strongly typed Color. I haven't performed extensive tests, but all of the methods here seem to support the x11 Color Names and #RGB format. | ![]() |
|
22 June 2016 | DataContractSerializer ReadObject | |
I recently authored a WebApi REST style service in Visual Studio 2015 which is being consumed by various client apps without any problem. Out-of-the-box WebApi services provide JSON and XML formatters, with JSON being the default one. The first clients apps for my service were .NET desktop apps and one written in Xamarin... | ![]() |
|
15 March 2016 | Nuget and AssemblyInformationalAttribute | NuGet • Visual Studio |
After uploading some updated Nuget packages I noticed they did not appear in the Visual Studio 2015 nuget.org browse results or in any package lists from the command line tools. A day later I was quite worried, so after running a bulk file comparison with the versions that were last visible in Nuget I noticed only one suspicious difference... | ![]() |
|
21 February 2016 | Hide Windows 10 useless folders | |
I just migrated over to a fresh development PC running Windows 10. It took many hours of work to remove most of the "junk" that clutters the desktop, processes and apps. I removed all tiles from the Start menu. I uninstalled every modern app that's possible (news, weather, sport, etc). I disabled services that will be unused... | ![]() |
|
14 February 2016 | Web API secret plumbing | Web API |
August 2021 Note: Most of this post is no longer meaningful after the arrival of .NET Core with significant changes to the ASP.NET libraries. The note below about dropping WebForms and preferring MVC to write web apps is now completely outdated and redundant. The arrival of Blazor Webassembly has driven a stake into the heart of server-side ASP.NET apps. I can write a Blazor app in about one fifth the time and with one fifth the code compared to a similar ASP.NET app... | ![]() |
|
14 February 2016 | WPF Binding Recommendations | Binding • WPF |
I just audited the binding code in a reasonably large WPF application I wrote in July 2015 and was embarrassed to find lots of subtle bugs. Some controls were not bound to the specific properties they depended upon, some controls were bound to irrelevant or incorrect properties, and some binding properties were orphaned and unused. | ![]() |
|
31 January 2016 | Preserving Encoding and BOM | |
I was running some files through Regex.Replace and a diff showed the first line of some files had changed, but the text looked the same. It turns out that by using StreamReader to read the input files... | ![]() |
|
27 January 2016 | IISExpress Trace/Log Files | |
I noticed by accident while using TreeSize Free that this folder:
MyDocuments\IISExpress\TraceLogFiles contained hundreds of log files taking over 120MB.
|
![]() |
|
21 January 2016 | Inter-Process Locking | |
Many years ago I had to share a file between apps running in different Windows processes, and I had to guarantee that only one process would update the file at any time. Web searches reveal lots of different code samples, and they're much longer and more complicated that what I remember of my old code. So after bumbling around for half an hour I finally rediscovered the simplest possible code... | ![]() |
|
16 January 2016 | Azure Table Combined Conditions | Azure |
I was getting BadRequest errors inserting rows into an Azure Table. I eventually noticed that some of the PartitionKey strings had \ (backslash) inside them. I then found various online arguments about which characters were forbidden and various silly workarounds, like base64 encoding all the bytes in the key string (which works of course, but is a completely ham-fisted approach). | ![]() |
|
16 January 2016 | Azure Table Key Encoding | Azure |
If you have multiple conditions that must be combined to build a complete Azure Table query, the code can get verbose, increasingly so if there are 3 or more conditions. You might finish up with a cluttered mess of code that uses GenerateFilterCondition and CombineFilter methods sprinkled with if statements. | ![]() |
|
08 December 2015 | WPF DataGrid MouseDoubleClick | WPF |
After migrating all of my desktop app development from WinForms to WPF many years ago, I was often frustrated by moving from the DataGridView control to the DataGrid control. | ![]() |
|
18 November 2015 | InternalsVisibleTo PublicKey | |
I had to write some tests which accessed internal members of an assembly. You just have to put this in the app project being tested: | ![]() |
|
30 August 2015 | Global IIS Logging | |
Up until several years ago Visual Studio included a C++ sample project which was a wrapper around the C API that could intercept IIS Logging events. The internal plumbing of IIS has changed many times since then and the sample vanished, which was a nuisance, as I was using it to track hits on my web sites in real-time and show them in a grid which sat at the bottom corner of my server's screen. | ![]() |
|
21 July 2015 | C# XML DOC include | |
I wrote some C# XML code documentation and neatly put it all in a separate XML file because it was referenced via <include> statements in template generated code. Why did only the <summary> appear and nothing else in the Sandcastle generated documentation? After a bit of swearing, I eventually noticed the tiny mistake of omitting the trailing /* from the path. A correct <include> statement might be like this... | ![]() |
|
15 July 2015 | WCF Custom Headers and Silverlight | Silverlight |
This post is now a part of computer history. See: Silverlight Death and Funeral. | ![]() |
|
03 May 2015 | Gmail send Authentication Required | |
An app that sends email notifications to my Gmail account stopped working sometime in the previous months (I wondered why no emails were arriving!). SmtpClient Send was throwing... | ![]() |
|
29 April 2015 | Bulk Nuget updates | NuGet |
This article is really old and the instructions are unlikely to work correctly any more. There might be some newer and safer way of performing bulk NuGet updates across many projects, but maybe that's just too dangerous in general these days. | ![]() |
|
25 April 2015 | Batch build vdproj | Installer |
As I mentioned in a different blog post, support for vdproj (Visual Studio setup) projects was removed in VS2010, then it quietly returned as an optional extension for VS2013. After resurrecting some old setup projects I decided I needed to build them in batch scripts. I remember several years struggling for an hour to find the correct syntax of the command required to batch build a vdproj file. | ![]() |
|
24 April 2015 | Solution Open with ... batch build | |
I often want to right-click a Visual Studio solution file (.sln) in Windows Explorer to ensure that it builds cleanly. I don't want to bother manually launching Visual Studio for the same purpose. Here's my way of doing this. | ![]() |
|
24 April 2015 | XmlReader/Writer and XElement | |
When reading or writing large amounts of XML you can use the XmlReader and XmlWriter classes to stream the data and avoid holding it all in memory. | ![]() |
|
01 April 2015 | Drop data from Windows | WPF |
This is a reminder to myself about what data is available when you drag-drop Windows Explorer files or folders onto a WPF control. I used this code to intercept and dump the Drop event: | ![]() |
|
27 March 2015 | Powershell execution policy | Security |
I only run Poweshell scripts a few times a year when they're needed for some particular task, such as clearing all Event Logs at once (which is handy). I always run the scripts inside the UI (PowerShell_ISE.exe) because whenever I run a script from a command prompt I get... | ![]() |
|
16 March 2015 | Custom Actions and Uninstall | Installer |
This is just a reminder and warning about the rare but infuriating problem where the uninstall events in a Visual Studio Setup Project custom action (CA) will not run. While experimenting with a simple Setup Project to test some CA code I was changing various project properties and various haphazard ways and installing and uninstalling over and over many times. At some point, the CA's uninstall events and method overrides stopped running. | ![]() |
|
14 March 2015 | Registry secrets and permissions | Security |
I tried to convince a product manager that we must not store user passwords in the application's SQL Server database in any reversible form. Plain text is a suicidal risk, and encrypted passwords lead you into the murky world of dealing with secret keys that encrypt the passwords and trusting who has access to those keys. I believe that it is highly objectionable to store passwords in any reversible form... | ![]() |
|
23 January 2015 | Web Site Folders and Visual Studio Find and Replace | Visual Studio |
For many years I have used Visual Studio for Find (Ctrl+Shift+F) and Replace (Ctrl+Shift+H) in files. I know there are countless utilities of different styles available to do this, but if you have Visual Studio then it conveniently provides all of the typical power options you would need (Regex, match case, sub-folders, file name patterns, history, etc). | ![]() |
|
15 October 2014 | Hashing Short Strings | Hash |
The ancient content of this post is redundant. Simply visit: Hashing Short Strings | ![]() |
|
03 October 2014 | sc.exe syntax trick | |
For the first time in 10 years I had to create a Windows Service manually. This was caused by an issue described in my previous post [now deleted] The installer was interrupted. I look at the sc.exe command documentation and start typing at the DOS prompt. | ![]() |
|
30 September 2014 | IIS REST Verbs give 404 and 401 | |
I'm writing a REST service implemented in a single ashx handler class that was added to an initially empty ASP.NET Project. I test drive the service by using Fiddler's convenient Compose feature where you can send a http request and see the response. | ![]() |
|
18 September 2014 | Post Build ILMerge vs LibZ | Visual Studio |
For many years I used the ILMerge.exe utility in Visual Studio post build events to merge multiple .NET assemblies into a single assembly. This is most useful when you want to distribute an executable file and its dependent library files as a single EXE file. For Framework 4.0 projects I would add something this to the post build event... | ![]() |
|
03 September 2014 | pkzipc extract to subfolder | |
I was trying to extract all files from a zip into a subfolder like this... | ![]() |
|
01 September 2014 | Real Random Numbers | Random |
July 2022 Update — The random.org and ANU Quantum web services are now behind paywalls. You have to register with both of them, even for free tier access, and the quota limits for free access are so cripplingly small that the services are now beyond the reach of hobby consumers. | ![]() |
|
31 August 2014 | Setup project user logging | Installer |
When working with Visual Studio Installer projects (vdproj project files) it's possible to create a class like this skeleton to perform custom actions during installer processing: | ![]() |
|
05 July 2014 | Dynamic C# code compilation | C# |
February 2025 Update — This old post original made in July 2014 has been updated to demonstrate how C# code can be dynamically compiled and invoked on both .NET Framework and .NET Core. | ![]() |
|
04 July 2014 | AppDomains from libraries in subfolders | |
Early 2022 note: The AppDomain class has been basically deprecated after the introduction of .NET Core and later frameworks. This article is therefore only meaningful for the traditional .NET Framework. For more information see .NET Framework technologies unavailable on .NET Core and .NET 5+. | ![]() |
|
18 April 2014 | Implementing SymmetricAlgorithm | Security |
In a previous post I answered my own question about how difficult it was to formally implement HashAlgorithm. It turns out you just override a handful of members and you have a class that behaves like the standard classes (MD5, SHA1, etc). | ![]() |
|
13 April 2014 | Implementing HashAlgorithm | Hash |
See the 2022 article titled CRC vs Hash Algorithms for a news update about the CRC and XXHash classes that are now part of the .NET Core class libraries. There is no longer any need to use borrowed code for CRC or SHA3. | ![]() |
|
29 March 2014 | Copying NTFS security | |
A few days ago I was shutting down Windows 7 and it suddenly produced a BSoD telling it had a SERVICE_EXCEPTION. I always reboot after something like this happens to be sure there's no permanent damage. Sadly, I found the following weird problems: | ![]() |
|
29 March 2014 | SNK, projects, users and key containers | Visual Studio |
It's always been irritating that when you add a strong name (snk) file to a Visual Studio project that it will make a copy of the file in the project folder. You can finish up with dozens of copies of the snk file scattered around your projects. | ![]() |
|
24 January 2014 | Parallel.For with a disposable class | C# |
A post into the ozdotnet list in Feb 2013 — Chaps, I think I have found the formally correct way of giving each Parallel ForEach thread its own copy of a disposible and unsharable class. There is an overload of ForEach that lets you do something at the start and end of each worker thread. | ![]() |
|
24 January 2014 | ftp.exe and passive mode | |
We discovered that a C++ app running in an Amazon instance could not communicate with the outside world to manipulate files via FTP. While trying to debug this terrible problem I used the built-in ftp.exe Windows app to try and simulate and solve the problem. I expected that the "vanilla" ftp program would be a good base-level way of testing the situation. | ![]() |
|
24 January 2014 | Manage IIS with AppCmd.exe | |
If you get confused about the relationships between IIS virtual directories, applications and pools, use this command... | ![]() |
|
24 January 2014 | ROBOCOPY in post build | |
To see a copied file list only and accept non-fatal return codes do this... | ![]() |