A developer’s view

Ramon's website

last update:

Are you looking at a similar window and you desperately need access to your database? You’re come to the right place, because there is a good way to recover access to the database without nasty tricks, third party software or losing any data. The not so-good options I had to recover a SQL Server database for a customer that changed its internal AD structure, so the database wasn’t accessible via Windows authentication anymore.

If you have accidentally ran a script and your current database was still set to ‘master’, then you end up with a pretty messed up master database. It doesn’t really hurt, but I like to keep my computer tidy. So I came up with a script that cleans up the mess again. To determine when the mess was created run the following query: SELECT * FROM sys.objects It will show you all the objects and the creation date.

This article is an updated of my previous January 2014 article SQL Server 2012 Express edition is a great database with a lot of potential. There are some limitations, but for a lot of applications this isn’t a big deal and SQL Server express is a great choice. For SQL Server 2012 Express edition, the following limitations exist: Each engine will use only up to 1GB of RAM memory. Each engine will use only 1CPU (with a maximum of 4 cores within that CPU).

I recently used a TabControl and required a different ContentTemplate per item, so I used datatriggers to change the ContentTemplate based on the current selected page. In theory this should work fine, but I found that changes to the ContentTemplate are not effectuated. How to reproduce Use the following XAML code to illustrate the problem. The property trigger based on the ‘IsMouseOver’ property changes the content template, when you hover over it.

WPF introduces the concept of routed events. There are different routing strategies, but the most commonly used strategy is the bubbling strategy. With the bubbling strategy, the event handlers on the event source are invoked. The routed event then routes to successive parent elements until reaching the element tree root or when a handler sets the Handled property. Always make sure that you set the Handled property, when you handle a routed event.

WPF control share no code with the old-style Win32 controls that are used in traditional Windows applications. The WinForms controls wrap the native Win32 controls and extend them in some areas. The WPF library complete rewrites these controls in native .NET code, so some differences may occur. In this post I will describe two small differences that might be annoying. Using US international keyboard on Windows XP Using a keyboard setting that allows composing letters with diacritics have some issues on Windows XP.

The TextBlock.GetPositionFromPoint raises a NullReferenceException in some cases. This method should return a TextPointer to the text that starts at the given position. In some cases it generates a NullReferenceException instead, which is clearly a bug. The internals of this method looks like: public TextPointer GetPositionFromPoint(Point point, bool snapToText) { if (this.CheckFlags(Flags.ContentChangeInProgress)) throw new InvalidOperationException(SR.Get("TextContainerChangingReentrancyInvalid")); if (((ITextView)this._complexContent.TextView).Validate(point)) return (TextPointer) this._complexContent.TextView.GetTextPositionFromPoint(point, snapToText); if (snapToText) return new TextPointer((TextPointer) this._complexContent.TextContainer.Start); return null } The call fails in the TextBlock.GetPositionFromPoint according to the call-stack.

The ScrollViewer control is a convenient control, when the content doesn’t fit on screen and you need some kind of scrolling to make all content accessible. I tend to use the mousewheel to scroll up and down, but this sometimes doesn’t work in WPF applications. It fails when you nest multiple scrollviewers, because the deepest ScrollViewer will always handle the MouseWheel message. Even if there is no vertical scrollbar visible or when it is disabled.

Today, I encountered a problem with WinForm’s ListView imagelist. When you assign a global imagelist to the listview, then the listview will remain in memory forever. When the ListView references other objects, then these objects won’t be collected too and you might end up with a huge memory leak. When does this occur? ListViews won’t be collected until the associated imagelist(s) is collected, when you don’t reset the SmallImageList, LargeImageList or StateImageList properties yourself.

It seems there is bug in the WPF resource architecture that can cause memory not to be released and causing performance and stability problems. The document describes when the problem occurs and why. During the development of a WPF application, we noticed that a huge amount of memory was used after a while. After profiling with the excellent .NET Memory Profiler v3.1 we found out that a lot of objects were not collected by the garbage collector.