RSSAmplifier

Blog

Egil Hansen's .com

Independent .NET developer and cloud architect available for contract work. Microsoft MVP, international speaker, open-source developer, and creator of bUnit.

egilhansen.comRSS feed ↗36 posts

Latest posts

Evolving your C# types without migrating stored JSON

Data models evolve, but the JSON payloads serialized from the old shapes do not go away. They sit at rest in databases, document stores, caches, queues, and on disk, and they keep arriving over the wire from APIs, Event Hubs, and other systems that have not upgraded yet. The moment I rename a property or restructure a type, deserialization of all that existing JSON breaks. My previous approach was…

Treat warnings as errors in Debug mode when an AI agent is detected

Treating warnings as errors is good practice for both humans and AI agents — it keeps the codebase honest. Pair it with an opinionated .editorconfig and analyzers like StyleCop, SonarCloud, or Meziantou, and you get consistent code with clear, actionable diagnostics from the compiler and the Roslyn analysis pipeline.

Verify snapshot tests and AI agents: disable the diff tool

I use Verify for snapshot testing in .NET projects. It is great, but there is one annoying edge case when an AI agent runs the test suite: a snapshot mismatch can make Verify ask DiffEngine to open my configured diff tool and wait for it to close.

Blazor Server: Stream large amount of data to JavaScript with cancellation

In a recent Blazor Server (.NET 8) project I needed to send a large amount of data to Plotly.js (+ 50 MB of data). Blazor already have support for streaming data from .NET to JavaScript, however, I wanted to also add support for compression of the data that is sent and cancellation of an ongoing stream of data, in case the user changes their mind and wants to view a different set of data, before…

SSIS: Using ASCII control characters anywhere in a SSIS package will break it

I noticed this oddity when I was reading a CSV file using SSIS. Sometimes the source file would have a the ASCII SUB control character in the first column on the last line of the file (see screenshot below):

SSIS: Lookup Transform not finding expected match with NULL values

If you use the Lookup Transform to perform lookups with columns that can be NULL, the Lookup Transform will fail to find expected matches because in a database world, NULL does not equal NULL. So how do we make the Lookup Transform match as expected when source column and lookup column can be NULL? We use ISNULL function, partial caching and a custom query in the Lookup Transform.

SSIS: Solution for Excel data source text truncation of column with more than 255 characters

When using SQL Server Integration Service (SSIS) Excel data source to import text from a column in a spreadsheet, the data source will automatically try to determine the maximum length of text in the text column. It does so by sampling the 9 first rows in the spreadsheet and measuring their length. If it does not find any column longer than 255 characters, it will set the columns type as DTWSTR…

SharePoint 2013: The server was unable to save the form at this time

This morning our freshly installed SharePoint Server 2013 server was refusing to let me save a simple form with a Lookup column to another list. Using the standard insert/edit form, the error message read:

Extra Tips for Debugging SharePoint Timer Jobs

There is an excellent guide over on MSDN on how to debug a SharePoint timer job from Visual Studio. However, it fails to mention that sometimes you need to restart the service that runs the timer jobs to allow debugger to set a breakpoint. In addition, sometimes a job will not show up in the job definitions list (Central Administration – Job Definitions), making it hard to manually start a job.…

SharePoint Foundation 2010 on Windows 7/8 – missing config.xml file

To install SharePoint Foundation 2010 on Windows 7/8, you need to modify the config.xml file. However, after extracting the setup files, the config.xml file was nowhere to be seen in the Setup folder. To get the installation going, I had to create the file myself. Here is the content that goes into it:

JSLink: The simple way to add and load multiple JavaScript files

It can sometimes be useful to specify multiple JavaScript files to use when rendering e.g. a field in SharePoint 2013. It could be that you have a JavaScript file with some shared code that you use in all your custom rendering, or you use a library such as jQuery. In either case, you need all the scripts loaded before you can start rendering.

How to add an Enterprise Keywords column to a custom list and enable Keyword synchronization in SharePoint 2013

This is a quick stepbystep guide to add an Enterprise Keywords column to a custom list and enable Keyword synchronization with Visual Studio 2012 in a SharePoint project. The SharePoint tools for Visual Studio 2012 have become a lot better in the latest edition, but a little extra work is required to get the Enterprise keywords column wired up correctly.

Nokia, please turn my f…ing volume back up again!

With the Windows Phone 7.8 update to my Nokia Lumia 800, Nokia suddenly decided that my hearing is precious and I am not able to take care of it myself... the volume is now capped at half of what it was before.

Quick and simple Drupal upgrade using FTP only

Running Drupal on a shared host usually imply you only have access to the webserver through FTP, i.e. no Drush or SSH to ease the upgrade process. The official upgrade instructions assumes you have shell access to your server.

Getting TypeScript, RequireJS, and Jasmine to play nice together in Visual Studio

Getting TypeScript, RequireJS, and Jasmine playing nicely together in Visual Studio turned out to be a bit harder than I had hoped.

SharePoint’s formula syntax can change depending on a sites regional setting

Sometimes very simple formulas like =IF([Column1]<=[Column2], "OK", "Not OK") can result in the unhelpful <cite"The formula contains a syntax error or is not supported"</cite error message, even though the formula in the example is perfectly valid according to the documentation, it still wont accept it.

Windows 8 + Hyper-V does not diable speedstepping

After enabling HyperV on my laptop running Windows 8, I noticed that Task Manager and Resource Monitor always showed the processor as running at full speed, as if Speedstepping was suddenly disabled. This is however not the case. What is really happening is that HyperV is virtualizing the CPU for the host OS (Windows 8) as well. Opening up CPUZ reveals the real clock speed and multiplier of the…

How to: Different keyboard layout for each program in Windows 8

Here is a quick tip for all of us who write and program a lot in one language, e.g. English, but also write in one or more languages, in my case, Danish. It is easy to switch between installed keyboard layouts, just hit the Windows Key + SPACE (in Windows 7 it is ALT + LEFT SHIFT).

Computer running slowly – it might not be Windows’ fault – it could just be your CPUs thermal protection

Conventional wisdom says that when a PC starts to run slowly and angry screaming at the computer screen ensues, it is time to reinstall Windows or remove some of the crapware that's been building up on the PC. However, it could be a hardware issue; it could be the computers cooling system that is unable to dissipate heat from the processor probably, causing the processors to lower its speed to 50%…

Remember the FeatureId when creating a custom ListInstance in SharePoint 2010

When creating a list instance manually in a SharePont 2010, it is important to remember to add the right FeatureId attribute to the ListInstance element, if the TemplateType attribute points to a list template which is not in the same feature as the one you are creating the list instance in. If you forget, you will get some very vague error messages.

SharePoint 2010: Easy registration of Event Receivers to a Content Type during Feature deployment

When registering a custom event receiver to a content type during a feature deployment using the SPEventReceiverDefinition class, you need the full assembly name and the full class name. However, during development, it can be tedious to keep track of the assembly names, so to make things easier we can just grap it using the typeof operator.aspx). This small reusable helper method makes this easy:

CSS trick: Semi transparent CSS background that works in all browsers

This simple CSS class will create a semi transparent background, letting whatever is underneath the element shine through. It works across all browsers, that means Internet Explorer 6.0 as well. The newest browsers will use the background:rgba(0,0,0,.75); setting, the rest (IE6IE8) will use the gradiant filter to achieve the same effect.

Get background image to resize with browser window using CSS and jQuery

Using a photo as a background for a web page can look pretty good, but making that photo fill out the entire browser window no matter its size and proportions is not straight forward, if you also want to keep the photo in its original aspect ratio. Not clear what I mean check out the demo page to see the effect in action (try resizing it).

Design by Contract should become this decades TDD

I am currently taking CSE 218 at UCSD, "Advanced Topics in Software Engineering Methods and Tools for Software Modularity", where we recently read the paper "Applying 'Design by Contract'" by Bertrand Meyer. I already knew a little about the concept, and after reading that paper and playing with the concept in a micro project, I am sold. I really think Design by Contract has a chance at being this…

Why platforms should be the pillar of every product

A few days ago Googler Steve Yegge accidently posted an internal memo to the world about Google's struggles with building products. As embarrassing for Steve as it might have been (it has now been taken of his Google+ page), it is a very interesting read that gives a good candid insight into a two of the biggest companies in our industry, Amazon and Google. Steve compares Google's productfirst to…

RIP Steve Jobs (1955 - 2011) – thank you for all your contributions

It is not often I find myself struck by the passing of a public figure, but with Steve Jobs it is hard not to feel touched. The man who has had such a great influence on the tech industry and the world in general, leaves us with a large collection of important innovations and ideas, that will continue to inspire for many years to come. I will leave you with this fantastic quote from his Stanford…

Drupal: Extending Markdown syntax to add CSS classes to images

Update June, 2013: As pointed out by Don Morris in the comments, PHP Markdown Extra now supports classes, making the below trick obsolete for this purpose. If you are using input filters such as the Markdown filter module, you may run in to a situation where the script behind the module does not provide you with all the formatting options you want.

Getting all DNS records form a Internet domain via nslookup

This is a quick and easy way to grab all DNS records from a domain. All you need is the name of the domain you want to query and the DNS server that is handling the domain. Here is how you do: Open up a command prompt and type: In the nslookup prompt, type: Hope this helps.

How to package fonts in .msi file for easy deployment

In this tutorial I will show you how to package custom font(s) into a Windows Installer .msi package for easy deployment to computers in a network through Active Directory. Alternatives is to use a VBscript solution or batch file solution, but I like this solution better as it allows me to deploy it through a AD group policy, it will automatically ensure that the fonts is only installed once, and…

Simple Ping/Reply Service for Unit Testing AJAX/XHR requests

To make it easier for me to unit test a OData JavaScript library I am working, I created a small HTTP handler that will reply back to a AJAX request with the headers, HTTP verb and query string it received. My initial thought was to do this through a WCF service, and while this is certainly possible, I found it much easier just to create a simple HTTP handler.

How to take control of style sheets in ASP.NET Themes with the StylePlaceholder and Style control

The problem is pretty simple. When using ASP.NET Themes you do not have much say in how your style sheets are rendered to the page. The render engine adds all the style sheets you have in your themes folder in alphabetic order, using the <link href="..." notation.

Simply way of adding a default item to a data bound DropDownList

I have always found it too difficult to add a "Choose xxxxx" item to the top of a DropDownList, when the DropDownList binds to a ObjectDataSource, SqlDataSource or similar. I almost always ended up just feeding the DropDownList its content from the code behind, even though it felt like something that should be possible directly. The control do have a AppendDataBoundItems property, but most of the…

System.Diagnostics + ASP.Net Web Site – remember to set compilerOptions="/d:TRACE"

Today I was looking at Ukadc.Diagnostics, an extension to the System.Diagnostics namespace, and decided to build a test website myself to get more familiar with it. After reading through Ukadc.Diagnostics Reference Example I thought it would be a homerun in the first try, but it turns out that without adding compilerOptions="/d:TRACE" to each compiler in the compilers section in the Web.config,…

C#/.NET: Safe way to convert UTC time to local time when databinding

After reading Scott Mitchell's article Using Coordinated Universal Time (UTC) to Store Date/Time Values, I decided to do as he suggest and use UTC for a web application I'm building at work. All in all it is fairly easy to deal with UTC in the .NET Framwork. There is a DateTime.UtcNow you can use instead of the regular DateTime.Now property, and there is a DateTime.ToLocalTime method that will…

CSS trick: Always show scrollbars

Update 2011: Since Internet Explorer now always just display a vertical scrollbar, all that is needed to force a scrollbar in all other nonIE browsers is this: I worked on a site a few weeks ago where the user wanted visible scrollbars no matter how much space the content takes up on the page. Internet Explorer is happy to oblige, just put in a overflow: scroll; in your CSS and your good to go.…

Quake dueling guide

Back in October 2005 when Quake 4 was about to be released I decided to write a guide to dueling in Quake. A few years back I was dueling on a fairly high level (at least by Danish standards) in Quake 3 and besides having some experience to share I also though an article like that would help build a good Quake dueling community in Denmark again, by helping aspiring Quakers get some tools to work…