WMI Filter for laptops

For filtering laptops in a WMI query there are several different approaches to find out if a system is a laptop or not. A suggested way found on the internet is following WMI query

SELECT * FROM Win32_Battery WHERE (BatteryStatus <> 0)

This works, but if you remove the battery from your laptop and keep the lLaptop on the power chord only this will not work. Then the laptop seems to be a desktop machine. A better approach is to use the following WMI-query:

SELECT * FROM Win32_ComputerSystem WHERE PCSystemType = "2";
Leave a comment

Posted by on September 29, 2014 in Windows Server


Tags: ,

Inlines and Run in TextBlock does not follow Language override

If you want to localize your application you generally override the LanguageProperty with your desired language:

    new FrameworkPropertyMetadata(XmlLanguage.GetLanguage("de-DE")));

As stated in the documentation every control should now use the – in this case – German culture. Well this is not the case. If you have a TextBlock and set the Text property then this works, but if you have a TextBlock with Inline elements, then the en-us culture is used.
This is very stange. Why is that the case? TextBlock inherits from FrameworkElement and because you have overridden the FrameworkElement.LanguageProperty this works. But if you use Inlines, such as Run, Italic, Underline, … those controls inherits from FrameworkContentElement and not from FrameworkElement for which you do not have overridden the corresponding DependencyProperty. This is the only reason why Inlines do not follow the application wide culture. As solution for that you have to override the LanguageProperty for FrameworkContentElements.

    new FrameworkPropertyMetadata(XmlLanguage.GetLanguage("de-DE")))

This does not work because it says that is is already registered. So a workaround is to override if for every class that is one inheritance hierarchy lower than FrameworkContentElement:

    new FrameworkPropertyMetadata(XmlLanguage.GetLanguage("de-DE")));

    new FrameworkPropertyMetadata(XmlLanguage.GetLanguage("de-DE")));

    new FrameworkPropertyMetadata(XmlLanguage.GetLanguage("de-DE")));

    new FrameworkPropertyMetadata(XmlLanguage.GetLanguage("de-DE")));

    new FrameworkPropertyMetadata(XmlLanguage.GetLanguage("de-DE")));

    new FrameworkPropertyMetadata(XmlLanguage.GetLanguage("de-DE")));

Now the Inlines in TextBlock follows the culture that you have specified

Leave a comment

Posted by on September 25, 2014 in C-Sharp



Done Building Project “X” (default targets) — FAILED.

If you use Team Foundation Server as build server and have a Database Project that is build on the server there is a chance that the build output succeeds without errors but the build result is “failed”. If you execute msbuild on the build server you can see that the DatabaseProject build succeeds with following output:

Done Building Project “X” (default targets) — FAILED.

Based on the documentation of the TFS-Build-Server any build output containing ERROR, FAILED,… is interpreted as a failed build, even though the msbuild script succeeded.
The problem is that you have not updated the SQL Server Data Tools. If you install the update on your build machine then the MsBuild-Script will succeed

Leave a comment

Posted by on September 19, 2014 in Team Foundation Server



TFS does immediately not see group member changes.

When adding a user to a windows/domain group (e.g. TFS-Users) that has access to a repository on Team Foundation Server it may be that this user does not get immediate access to your Team Collection. This is because Team Foundation Server caches the user that are present in the group TFS-Users. Therefore any user change on the windows/domain group, either removal or addition, will not be reflected immediately to the Team Foundation Service. The solution is to wait some amount of time, since Team Foundation Service will re-query the windows/domain user group for eligible users every hour.

Note: It does not work to shut down the IIS-Webpage and restart it, this will not force a re-query of the windows/domain group.

Leave a comment

Posted by on September 11, 2014 in Team Foundation Server



The located assembly’s manifest definition does not match the assembly reference

“System.IO.FileLoadException: Could not load file or assembly \”System.Windows.Interactivity, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35\” or one of its dependencies. The located assembly’s manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)”:”System.Windows.Interactivity, Version=, Culture=neutral, PublicKeyToken=31bf3856ad364e35″

Looking in my solution explorer I can see I have referenced System.Windows.Interactivity, Version=


But why does he complaint that version is not found. The short answer for the problem is that another referenced library references itself System.Windows.Interactivity with version Therefore, because version is loaded by the version is not found.

The solution is to configure a assemblyBinding in app.config.

This is done as follows:

<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
        <assemblyIdentity name="System.Windows.Interactivity" 
                          culture="neutral" />
        <bindingRedirect oldVersion="" 
                         newVersion="" />
1 Comment

Posted by on February 20, 2014 in C-Sharp


sql71502 when using INSERTED keyword

Recently I had a strange exception when using the INSERTED keyword. It always mentioned that the Id property does not exists on table X.


The solution is rather simple. Just put the scheme name to your table then the exception is gone.


Leave a comment

Posted by on January 20, 2014 in SQL


Constant Enum: Circular definition

If you have declared an enum field as constant you may get following exception:

The evaluation of the constant value for … involves a circular definition.

The code where this exception appears looks like:

private const Parity Parity = Parity.None;

Well, thats strange. There is no error. I declare a constant field with the same name as the name of the type. This is allowed, because I can also write following line of code, and this would compile

private const String String = "HELLO"

The problem with enums is that the compiler interprets the third Parity not as the name of the enumeration but as the name of the field. Hence, we have a circular reference because the constant is defined by the constant itself. To solve the compile error you have two options: either you add the fully qualified name to the third Parity value or you change the name of the field.

private const Parity Parity = System.IO.Ports.Parity.None;
private const Parity ParityValue = Parity.None;

If you use tools like ReSharper that cleans up the redundant qualifiers than I would suggest you to use the second option.

Leave a comment

Posted by on April 29, 2013 in C-Sharp


Tags: ,


Get every new post delivered to your Inbox.