Thu, Sep 23, 2021
PostgreSQL has some fancy types like the array type. But its not obvious how to return e.g. an int[] or an uuid[] in a single row from Dapper.
In fact the first hit on StackOverflow said it was impossible.
Not so… with a little insight, luck and duct tape you can do anything. It’s actually quite easy.
If you use Dapper and NpgSql “out of the box” you will get an error “Invalid type owner for DynamicMethod” if you go for an array in your select like this:
Sun, Mar 14, 2021
Phaser 3 is a great javascript game engine for developing browser games. As far as I understand the new versions
follow the general trend and is generally developed in typescript.
However it does not automatically follow that its easy for game developers to setup their own
environments to develop their Phaser games in typescript. For historical reasons (I guess) there is not a lot of
guidance to be found online.
Sat, Jul 18, 2020
I just released 3 small libraries for configuring secrets in a .NET Core or Full framework app.
Its a simple key/value store with encrypted values and it supports .NET Configuration (both Core and Full Framework)
Its called QuickVault and consists of a .NET standard base library installed with:
Install-Package QuickVault
A library for .NET Core configuration:
Install-Package QuickVault.Configuration.Core
And a library for .NET full framework configuration:
Install-Package QuickVault.Configuration
What does it solve
You know the problem. You use a cheap web hosting company where you only have limited access to the server, and you do not want your precious secrets, password, api keys etc. to be openly accesible in the web.config or appsettings.json You could use something like Azure Key vault but if you had access to that you would probably use Azure for the website as well.
Wed, Aug 21, 2019
if you use the service Netlify for a static site you get the option of doing automatic minification of your javascript when the site is deployed.
Its as easy as setting a checkbox.

I recently used on a site, and to my surprise it did not work (since Netlify usually works like a charm)
After doing some back and forth with Netlifys support and trying the advice in this post it still did not work unfortunately.
Tue, Oct 30, 2018
Just for fun and to have a little special something for the blog I decided to do some animated GIFs of Stick Figures. So I created a little tool called “StickFigure” (Windows only sorry) designed for making animated Match stick men and other drawings like that.
The tool works like this:
- Plan your animation
- Draw the key frames
- Generate in between frames.
- Generate PNGs
- Generate JPGs
- Generate the GIF
For a more detailed description see the Readme
Mon, Sep 24, 2018
When I published my blog with the shiny new format this morning, SPAM started flowing in IMMEDIATELY. Less than 10 minutes after I published, the first “Viagra” message was added as a comment.
And then it flowed in, in a steady pour, approximately one spam message every 45 minutes.
My old blog used Akismet to filter out the worst spam. Unfortunately Akismet does not work well with Staticman yet, instead I decided to try ReCaptcha.
Sun, Sep 23, 2018
It has been 4 years since my last post, and 7 years since I posted regularly. Phew… time flies. The reason has not been a lack of subjects but more that other things were more fun, like making all sorts of games for iPhone, Apple TV, XBox and PC. I could have shared some of the experiences but I was too lazy to update the blogging tech. from the old DasBlog engine to something contemporary.
Sun, Jun 8, 2014
I must admit that I prefer SVN over GIT due to the (in 2014 only slightly inferior) tooling and due to the illogical naming and structuring of commands and parameters.
But still GIT has a lot going for it, and I needed the GIT submodule command for a private project of mine i.e. something that I want to sell
and therefore not place on github.
So away with SVN.
On my trusted Synology I have the SVN server installed which was basicly just plug and play. So I figured that installing the GIT server package would be just as easy.
Wed, Sep 7, 2011
I finally got around to upgrading and releasing Solzip for VS2010.
Solzip is a tool for zipping Visual Studio C# solutions from a right click menu in the solution explorer. You can also Zip individual projects.
You can install it from http://solzip.codeplex.com or from the Extension Manager in Visual Studio.
You can choose to install a command line version or the Visual Studio version either one that requires MME or a single file install which includes MME. Furthermore there is a GAX version for the ambitious.
Thu, Jul 28, 2011
When making the WP7 game Photo Challenge we quickly agreed that we needed leaderboards. The problem is that is time consuming to build a scalable high quality leaderboard service tailor made for our game and secondly we would have to pay for server storage for a game that statistically won’t make a dime anyway. This meant that we searched for a ready to use leaderboard service. It wasn’t easy to find. But then a miracle happened. We found the amazing Mogade.com.
Tue, Jul 26, 2011
I and a team of 1 graphic artist and 1 sound engineer just finished our first game for Windows Phone 7 called “Photo Challenge” a few weeks ago. We planned this pretty simple game to get experience before going for the big hit. The concept has been seen before. A Puzzle Slider where you have to solve a square puzzle with 2x2, 3x3, 4x4, 5x5 or 6x6 squares with one square missing. The Puzzle can be made from you own photos or from some build in ones. Here is a few screenshots:
Sun, Jul 24, 2011
When we were to publish a free version of our new Windows Phone Game Photo Challenge I wanted to maintain both the free and paid version in the same Repository. I wanted the solution file and project file for the new free app to use the same source files as the paid app. This gave some headaches because there needs to be a physical WMAppManifest.xml file for each App. I googled various approaches but I finally made up an entirely different approach which I thought fitted our project best. Here is the steps I took:
Mon, Apr 18, 2011
I like the new look and feel of IE9 but it is not without startup problems though. If you want to use Google as your favorite search provider what do you do ? Well lots of places on the web tells you to go to “Internet options” –> Change Search Defaults (Settings) and then press the lower left link “Find more search providers…”.
I did this but was perplexed. Google was not listed !
Tue, Aug 31, 2010
Guidance Automation 2010 Bug: The imported project “C:\Microsoft.Practices.RecipeFramework.Build.targets” was not found
The new Guidance Automation Framework GAX 2010 and GAT 2010 which is installed through the Extension Manager in Visual Studio 2010, provides a nicer usability experience compared to the Visual Studio 2008 predecessor. It is installed using the new vsix installer. A vsix install is much nicer than the old msi install since it integrates into Visual Studio. You can uninstall using the Extension Manager and if a new version comes out it should appear on the Updates tab of the extension manager.
Sun, Jun 13, 2010
Imagine that you want to make an extension for Visual Studio 2010 that creates new custom right click menus for the Solution Explorer. Imagine that you could do it by just implementing a good old .NET interface like this:
public class MenuManager : IMenuManager
{
public IEnumerable<IMenuItem> GetMenus(ContextLevels menuForLevel)
{
var menuItems = new List<IMenuItem>();
var menuItem1 = new MenuItem("My Menu1");
menuItems.Add(menuItem1);
var menuItem2 = new MenuItem("My Menu2");
menuItems.Add(menuItem2);
return menuItems;
}
public string MainMenu()
{
return "My Main Menu";
}
}
Well it turns out you can. In MME I have helped you do exactly that. No more using the convoluted add-in model of Visual Studio to accomplish this goal. And it is also much simpler than using GAX/GAT (that can do so much more to be fair).
Wed, May 12, 2010
Click and double click in XNA Games
Windows developers who are used to click events in WinForms, WPF or Silverlight might miss click and double click events, but because of the game loop where everything is drawn and updated every few milliseconds an event based approach is probably not a good idea in most cases. Not so much because of the performance of an event based approach, but more because the complexity is overwhelming. If several users clicks and double clicks several keys on the keyboard simultaneously, how would you decide which of these are clicked and in which order, and further more it is not obvious to subscribers of the events that they are in the game loop, so they might do code which performs inadequately.
Sun, Mar 7, 2010
In Microsoft CRM you have no choice when doing updates to the database. You have to use the CRM Web Service.
Microsoft does not support direct SQL updates of the underlying SQL Server tables, because of the behind the scenes CRM magic.
The Web Service is OK for small amounts of data. But recently I had a case where I had to code an import of a spreadsheet with up to 100.000 rows into CRM.
Fri, Nov 13, 2009
In the Day View project I needed to open a Windows 7 Sticky Note programmatically and write to it. Unfortunately I found out that there is not an API for the Sticky Notes application. At least not a managed one.
So I had to fake it and make my own API. I have made a small class that basicly uses Process.Start to open the program, and SendKeys to write to the Note.
Fri, Nov 13, 2009
I am currently developing the game Klimakonflikt with 5 other guys. It is a Retro arcade game, Pac-man style, with nice 2D Graphics and music. Here is a screenshot from the game:

The current release, documentation and source code can be downloaded from here http://klimakonflikt.codeplex.com
The game is inherently for 2 players but we are working on the single player edition. The AI in the current release is pretty daft, but in the next release it will be much improved. Also we are working on a WPF leveleditor, powerups and other fun stuff.
Tue, Oct 20, 2009
Last friday (the 9th) just one day before the deadline I finished my application for the Windows 7 Contest. “DayView” here is the description I made for the contest:
“DayView provides an overview of the appointments in all your calendars by a clever use of the Windows 7 Task bar. It shows your appointments, and you can scroll through them with toolbar buttons, and create Sticky Notes for the most important appointments. DayView uses MEF for a plugable architecture. It comes with plugins for Outlook and Sunbird.”
Mon, Aug 3, 2009
I must admit that I have never understood why it was fun to solve Sudoku’s. But as a programmer I was fascinated with the idea of making the perfect Sudoku puzzle generator algorithm from the very first time I heard of Sudoku. Of course I wanted to make it so general that it could not only make the boring old 9x9 sudoku. But sodukus of any size 4x4, 9x9, 16x16, 25x25 and so on…
Wed, Jul 15, 2009
Just released version 1.2 of SolZip my convenient tool for Zipping Visual Studio 2008 solutions
The major improvement is a single install for SolZipMME, so you won’t have to install ManagedMenuExtensions beforehand.
The release notes are here:
- Bug Fix: when multiple projects where referering to the same file it was added to the archive multiple times.
- SolZipMME uses SaveFileDialog instead of FolderBrowserDialog for Zip files.
- A single file installer for SolZipMME.
- Clipboard functionality now works on Vista / Windows Server 2008.
- SolZipGuidance changed. The menu will no longer appear on projects that are not C# projects. SolZipMME not changed.
- Support for $(SolutionDir) and $(ProjectDir) placeholders added
- Now works on Windows Vista even if UAC is not turned off
Enjoy…
Mon, Jun 29, 2009
I just released version 1.1 of SolZip which can be downloaded from the download page at the SolZip site.
The new action packed version contains one major improvement, one bug fix, and a few name changes:
Now Source Control bindings for TFS and SCC can be removed from sln and csproj files. The default for all 3 UI’s is that the bindings are removed, but you can optionally choose not to remove them. Feel free to contact me if you need bindings from other source control vendors removed.
A bug fixed that made WinZip clients give a warning when unzipping certain archives made by SolZip. The warning was given when there was .. (2 dots) in a path in one of the zipped files.
The Name SunZip.exe for the commandline tool was changed to SolZip.exe. Because SunZip sounded too much like UnZip.
The Name SolutionZipper changed to SolZip everywhere. Except for SolutionZipper.dll which has been changed to SolZipBasis.dll
In the next version I will try to include ManagedMenuExtensions in the install so you won’t have to run more than one setup to install SolZipMME.
Thu, Jun 18, 2009
Here is my take on the Best practice Dispose pattern for most situations. It is heavily influenced by Juval Löwy from IDesigns book “Programming .NET Components”, and some other sources which I no longer remember, since I made it a few years ago and have stuck to it ever since. Here it is:
public class Class1 : IDisposable
{
private bool m_IsDisposed;
~Class1()
{
Dispose(false);
}
[MethodImpl(MethodImplOptions.Synchronized)]
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
private void Dispose(bool isDisposing)
{
if (m_IsDisposed)
return;
if (isDisposing)
{
FreeManagedRessources();
}
FreeUnmanagedRessources();
m_IsDisposed = true;
}
protected virtual void FreeManagedRessources()
{
//Free managed ressources here. Typically by calling Dispose on them
}
protected virtual void FreeUnmanagedRessources()
{
//Free unmanaged ressources here.
}
}
Another thing is that you can inherit the class and override the FreeManagedRessources and FreeUnmanagedRessources as needed.
Mon, Jun 15, 2009
I just released a new codeplex project SolutionZipper which makes it a breeze to zip compress your visual studio solutions and projects. “What’s wrong with WinZip you might Ask”. Well WinZip has no knowledge of Visual Studio Solutions, which means it will compress everything in the folder, including bin / obj folders and other random debris.
I accomplish the compression by using the following algorithm:
- Iterate over all items and projects in the sln file and zip each of these.
- Zip the sln file itself.
- Iterate over all items in the csproj files and zip each of these. The iteration is done using Linq to Xml of course.
- Zip the csproj file itself.
As you might have guessed SolutionZipper only works for C# projects, and is only tested with VS2008.
Sun, Jun 14, 2009
I was using my codeplex project ManagedMenuExtensions recently when I realized that it threw an Exception, when clicking on a menu attached to a C# project under a solution folder. The reason was that the object which normally contained an EnvDTE.Project when a project was clicked contained null, when this project was contained in a solution folder.
I normally use this code to get at the selected project (m_VSStudio is the DTE object of the current solution):
Wed, May 6, 2009
My favourite RSS reader is GreatNews. First of all it is a standalone application, and secondly it is portable, which means I can install it on a USB key or better yet in my Dropbox which is what I do.
Well to be fair it is not portable in the purist way because it caches some stuff on the computers harddrive, but that is only for performance, so functionally GreatNews IS portable.
And GreatNews is very fast, which is just one more reason to love it.
Fri, May 1, 2009
If you want to Execute something on each element of the result of a Linq expression. You can either loop over the result using foreach(…) or turn the result into a List using .ToList(), and then use .Foreach(…) on the resulting list. Like this:
(from excep in ErrorList
where excep is ArgumentException select excep)
.ToList().ForEach(e => Console.WriteLine(e.Message));
This is ugly, and I prefer to make my own Extension method for IEnumerable<T> called Execute(...):
Tue, Apr 7, 2009
I recently was in a company where I created the coding standard. Mostly by referring to the great standard from IDesign but with a twist of company specific things. When C#3.0 came out I couldn’t find any coding standard material on the new stuff out there on the web. So I was forced to think…
My thoughts on the var keyword, is that it should be used extensively. But I place a restriction on it. You should only use it if the type of the object is explicitly readable from the line.
Wed, Mar 18, 2009
What is Linq ? You probably think you know the answer, Linq is after all already quite dated. Well in my experience chances are you only know part of the story. Most of the people I have met have a slight misconception of Linq which limits their use of this great technology.
Let me explain. Linq of course means “Language Integrated Query”, we all knew that. This basically refers to the syntactic sugar that Microsoft has poured over the C#3.0 language. I.e the from, where and select keywords and a few more.
Fri, Mar 13, 2009
Any windows user is familiar with Windows Explorer but were you aware that one can access an ftp site or WebDAV enabled site using the Windows Explorer ? I myself haven’t really been looking in to this, since I have been using Filezilla to upload files to my website, but why not use Windows Explorer ? It is always at hand with the Windows+E keystroke.
As an example I will show you have to access the http://live.sysinternals.com site via the Windows Explorer since it is a WebDAV enabled site with anonymous access. The site contains all the famous tools from Sysinternals a company which was purchased by Microsoft.
Wed, Mar 11, 2009
Currently I am looking into taking over a huge enterprise legacy system written mostly in C#, but also some C++. The numbers are staggering several million lines of code, 1200 GUI screen, mostly WinForms, about 750 C# projects, 150 solution files, just to mention a few. In all about 4 times larger than the largest enterprise system I have previously been working on.
Just building and deploying the system is a pretty big task since due to events beyond my control I basicly only have the sourcecode and nothing else. Not quite true because there are some documentation, but buried in the thousands of files.
Sun, Mar 8, 2009
When I post code blocks in this blog. It would be nice if they look like, well, code. So I looked at what Scott Hanselman had done, he is after all one of the creators of the blogengine I use: “Dasblog”
In this post Scott explains how to do it. He explains how to add Javascript from a project called SyntaxHighlighter and use a plugin called precode for Windows Live Writer. Well I use WLW too, so this is perfect for me.
Tue, Feb 24, 2009
This is the first post of my new blog. Hope
you will like it. My plan is to blog about my favourite topic - .NET and other
more or less related technologies. I hope to post regularly but I will keep my
ambitions low and plan only to post once every month ! Perhaps with a larger
more in-depth blog post every second month. This is not for lack of subjects,
but because I know myself. Work, family and fitness training often comes before
late night programming and researching new stuff.