The Wiert Corner – irregular stream of Wiert stuff

Jeroen Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My work

  • My badges

  • Twitter Updates

  • My Flickr Stream

    20120127-Microsoft-Visual-Studio-2010-New-Work-Item-menu-still-loading...-(try-again-in-a-moment)

    20120127-Microsoft-Visual-Studio-2010-Cannot-navigate-to-definition.Disable-this-productivity-power-tool

    20120127-Microsoft-Visual-Studio-2010-Cannot-navigate-to-definition

    More Photos
  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 366 other followers

Archive for May, 2010

#fail: Facebook has changed their mail domain to facebookmail.com

Posted by jpluimers on 2010/05/28

Recently, facebook started to complain that my email is not valid any more:

Please update your email address
Our systems have detected that valid.email@example.com is no longer a valid email. Facebook requires all users to maintain an active contact email. Please enter and confirm a new contact email below:
New Email: XXXXXXXX
If you believe you have received this message in error, please reconfirm your current email.

Note I changed my facebook email address in the quote above and log below, but the unchanged one is valid, and accepts mail. Read the rest of this entry »

Posted in Opinions, Power User | 11 Comments »

.NET/C#: comparison is a 101, or isn’t it?

Posted by jpluimers on 2010/05/26

In C# (well, actually: .NET), there are a couple of ways to compare things:

  • the built-in equality operator (==) which translates to the IL instruction CEQ
  • an overloaded equality operator (operator ==) that a class or struct can introduce
  • the virtual Equals method that is introduced in System.Object and which you need to call explicitly

Sometimes, this leads to confusion, for instance, given

object one = 0;
object two = 0;
bool same = one == two;

what would you expect the value of same to be?

Actualy, the value is false.

Why?

The reason is that the operator == does not call the System.Object.Equals method.
So the System.Int32.Equals method is never called.

What happens in stead, is that the CEQ instruction is called.
Since both the integer zero values have been boxed into two objects (referred to by one and two), the CEQ will perform the comparison on the object references.
Even though both zero values are the same, both objects have a reference to a different spot in memory (the contents of both memory spots then are the same zero value).
Since one and two refer two different memory locations, the value of same becomes false.

Similar things hold for most types, unless they overload the operator ==.

System.String is a special type.
Even though it not a value type (it is derived from System.Object, not SystemValueType), it behaves like a value type.

One of the things that string does is overload the operator == (and overload the operator !=):

public static bool operator ==(string a, string b)
{
    return Equals(a, b);
}

So even though one and two are potentially* referring to different locations, their content is compared, and same becomes true.

string one = "Foo";
string two = "Foo";
bool same = one == two;

*Now lets see these memory locations:

object one = "Foo";
object two = "Foo";
bool same = one == two;

Surprise! Here too, same becomes true.

What happened here is that when the compiler compiles two identical strings into an assembly, they are interned and end up at the same memory location.

Conclusion:

Comparison in .NET is not always 101.
It depends on the types involved, value types versus reference types, boxing, interning and the overloaded operator ==.

–jeroen

via The Lounge – CodeProject.

PS:
Another special thing about strings is that they are immutable:

A String object is called immutable (read-only) because its value cannot be modified once it has been created. Methods that appear to modify a String object actually return a new String object that contains the modification. If it is necessary to modify the actual contents of a string-like object, use the System.Text.StringBuilder class.

via String Class (System).

PS2:

Some other interesting links on comparison, interning, etc:

Posted in .NET, C#, Development, Software Development | Leave a Comment »

Happy Towel Day

Posted by jpluimers on 2010/05/25

Don’t forget to bring your Towel today

–jeroen

Posted in .NET, About, Delphi, Development, Opinions, Personal, Software Development | 1 Comment »

“Yoda Conditions” (from: stackoverflow – New programming jargon you coined?)

Posted by jpluimers on 2010/05/25

Having done quite a bit of C and C++ work in the past, I often still use “Yoda Conditions”, especially in environments where you have both = and == as an operator.
So, in a boolean expression, I often put the constant to test in front of the test.

I recently learned at stackoverflow that quite a few people call these “Yoda Conditions”:

“Yoda Conditions”— the act of using if(constant == variable) instead of if(variable == constant), like if(4 == foo). Because it’s like saying “if blue is the sky” or “if tall is the man”.

Thanks to dreamlax for helping me find that.

This is a problem in languages that have both the = and == operators, and the result of an assignment itself is also a value (i.e. allowing a = b = true). Read the rest of this entry »

Posted in .NET, C#, Delphi, Development, Java, JavaScript, Software Development | 17 Comments »

Visual Studio 2010: macro to change Target Framework Version for solution (by Scott Dorman)

Posted by jpluimers on 2010/05/21

Scott Dorman udpated his macro to change the target framework version for all projects in a solution to Visual Studio 2010 and published the new macro on CodeProject.

His new macro now supports these target frameworks:

Notes:

  • The links are to the download pages of the frameworks; look for “Standalone version” or “Full installer” for non-bootstrap download.
    (version 1.1 can be downloaded here, but is not supported in VS2010)
  • The “Client Profile” versions are stripped down versions of their “Full” counterpart.

–jeroen

Posted in .NET, C#, C# 2.0, C# 3.0, C# 4.0, Delphi, Development, Prism, Software Development, Visual Studio and tools | Leave a Comment »

Telnet for Windows Vista & Windows 7

Posted by jpluimers on 2010/05/20

I wrote about Telnet for Windows Vista & Windows 7.

These steps are even easier:

  1. Press the Windows key
  2. type “turn windows features on or off”
  3. choose “Telnet Client”
  4. press OK
  5. wait a few seconds for the install to complete

–jeroen

Posted in Power User, Windows, Windows 7, Windows Vista | 1 Comment »

Solution for “Error code: 2147500037″ while printing in Windows 7

Posted by jpluimers on 2010/05/20

Recently I got the messagebox below with “Error code: 2147500037″  when I used Windows 7 to print some settings (in this case the homegroup password, so I could store it in a safe place).

---------------------------
Your homegroup password couldn't be printed
---------------------------
An error occurred while Windows was trying to print your homegroup password. (Error code: 2147500037)
---------------------------
OK
---------------------------

It seems I am not the only one having this problem, and the solution was simple:
Windows 7 cannot print certain things when Internet Explorer is not the default browser.

Or in other words: this error message means: “Windows 7 cannot print this for you because it needs the default browser to be Internet Explorer“.
Was it that hard for Microsoft phrasing the message in such a way?

Changing the default browser is simple (some of the steps are in screenshots below): Read the rest of this entry »

Posted in Power User | 12 Comments »

Control the VMware VMs from the commandline: vmrun – the successor of vmware-cmd

Posted by jpluimers on 2010/05/19

In the process of upgrading from VMware server 1.0 to 2.0, I found out that vmware-cmd.bat has been replaced by vmrun.exe.

The command-line options are different, and this link explains the vmrun command-line options in detail (well, much better than the vmrun.exe built-in help). The official documentation is available as a PDF.

One of the changes I had to make was from: Read the rest of this entry »

Posted in *nix, Power User, VMware | 2 Comments »

ThinkPads beep during certain key combinations – found the cause

Posted by jpluimers on 2010/05/18

I’ve had an annoying beep on my thinkpad whenever I tried to write CD quickly.

It particularly shows when you press these three keys at the same time:

Shift+CD

Recently, I googled for the symptom to find out the cause.
Below are a few links I found, but this is the actual cause (thanks Kriston!): Read the rest of this entry »

Posted in Power User | Leave a Comment »

sun Java JRE 1.6.0.20 direct download for Windows

Posted by jpluimers on 2010/05/17

Edit:

20110904: Not sure why this MSI file does not work any more, but the comment below is correct: the downloaded MSI fails.
I’ve left the text below as is, just in case someone figures out why it fails.

–jeroen

Got the direct download from the error dialog because the network connection got interrupted:

—————————
Error – Java(TM) Installer
—————————
Download Cancelled by User: from=http://javadl-alt.sun.com/u/ESD6/JSCDL/jdk/6u20-b02/jre/jre1.6.0_20-c-l.msi, to=C:\Users\user\AppData\LocalLow\Sun\Java\jre1.6.0_20\jre1.6.0_20-c-l.msi
—————————
OK
—————————

Always convenient having a direct download URL :-)

–jeroen

Posted in Power User | 3 Comments »

Duplicate Shortcuts IE8 configuration dialog – Alt-N binds to “No” and “Next”. Are UI designers ever going to learn to be nice to keyboard users?

Posted by jpluimers on 2010/05/17

Duplicate Alt-N shortcut: No / NextFor every (re)install, IE8 is usually part of the installation.
So, for the upteenth time, I came across the dialog on the right.
This time Alt-N is bound to both the “No” choice as well as the “Next” button.

–jeroen; wishing UI designers would learn to pay more attention to keyboard users…

Via: 20100516-UI-Duplicate-Shortcuts-IE8 on Flickr – Photo Sharing!.

Posted in Development, Software Development, UI Design | Leave a Comment »

Twitter hickup – “older tweets are temporarily unavailable” #fail

Posted by jpluimers on 2010/05/17

Where broadcasting fails.

Older tweets are temporarily unavailable.

via Twitter / Search – #osdorp.

Posted in Opinions | 1 Comment »

Zondag nog steeds off-line: Nuon | Mijn Nuon is niet beschikbaar van zaterdag 12:00 tot 22:00

Posted by jpluimers on 2010/05/16

Ogemak; en zondag. Spellen en communiceren blijft moeilijk, niet alleen voor een klein bedrijf als het mijne...

Spellen en communiceren blijft moeilijk, niet alleen voor een klein bedrijf als het mijne...

Van de NUON site:

Mijn Nuon is niet beschikbaar

Mijn Nuon is vanwege onderhoud tijdelijk niet beschikbaar. Het onderhoud duurt van zaterdag 15 mei van 12.00 uur tot zaterdag 15 mei 22:00 uur.

Onze excuses voor het ogemak.

Wij danken u voor uw begrip.

via Nuon | Mijn Nuon is niet beschikbaar.

Posted in Opinions | Leave a Comment »

Wie legt De Telegraaf even uit wat “terughoudend” is? #ziekelijkenieuwsgaring #telegraaf #jolandevandergraaf

Posted by jpluimers on 2010/05/14

Wie legt De Telegraaf even uit wat “terughoudend” is? en Gespuis: Telegraaf interviewt Ruben in Libie.

Jolande van der Graaf - de 'Journaliste' die het stuk durfde te publiceren @!#$

image courtesey of HP/De Tijd

De Telegraaf (de “journaliste” rechts  - Jolande van der Graaf – publiceerde het !@#$) belt met het enige overlevende jongetje van de vliegram in Libië.
De jongen wiest toen nog niet eens de rest van zijn familie in het vliegtuig dood was.
Nu staat hij met naam, toenaam en foto’s in de krant?

(nee, een link naar het artikel komt hier niet, dat zou te makkelijk zijn)

Hallo!
Fatsoen???

–jeroen

Via: Wie legt De Telegraaf even uit wat “terughoudend” is? – The Amazing Retecool Goldmember
en Gespuis: Telegraaf interviewt Ruben in Libie

Posted in Opinions | Leave a Comment »

.NET – Putting a base in the middle (Eric Lippert – Fabulous Adventures In Coding)

Posted by jpluimers on 2010/05/14

I always tend to recompile assemblies when something changes they depend upon.

But now I’m even more careful after reading Fabulous Adventures In Coding : Putting a base in the middle.
Especially his checklist is important.

When you use a newer version of an assembly you depend on:

(1) at the very least test your derived types with the new base type — your derived types are relying on the mechanisms of the base types; when a mechanism changes, you have to re-test the code which relies upon that mechanism.

(2) if there was a breaking change, recompile, re-test and re-ship the derived type. And

(3) you might be surprised by what is a breaking change; adding a new override can potentially be a breaking change in some rare cases.

–jeroen

Posted in .NET, C#, C# 2.0, C# 3.0, C# 4.0, Delphi, Development, Prism, Software Development | Leave a Comment »

Windows 7/ Vista: How to access Administrative Shares (C$, IPC$, …) via PaulSpoerry.com

Posted by jpluimers on 2010/05/13

A while after installing a new copy of Vista or Windows 7, I usually want to be able to access the administrative shares (like C$, Admin$, IPC$, etc).

On Windows 7 and Vista, those are by default not enabled.

To enable them, import this .reg file into the registry:

Windows Registry Editor Version 5.00

[HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System]
"LocalAccountTokenFilterPolicy"=dword:00000001

You need to reboot your system once after this registry change.

–jeroen

via How to access Administrative Shares on Vista C$ | PaulSpoerry.com.

Posted in Power User | Leave a Comment »

.NET/C# – determining the hardware acceleration support for your WPF apps

Posted by jpluimers on 2010/05/13

When you want to deploy WPF, it is important to check if you have sufficient hardware acceleration for your apps.

The most important things to check is the RenderCapability.
It gives you the  Tier on which graphics is rendered.

The Tier tells something about hardware acceleration support, including a broad estimate of the pixel shader and vertex shader levels and DirectX versions.

Currently, there are 3 tiers: Read the rest of this entry »

Posted in .NET, C#, C# 3.0, C# 4.0, Development, Software Development, WPF | Leave a Comment »

Reading tea leaves – Danny Thorpe

Posted by jpluimers on 2010/05/12

A short while ago, Danny Thorpe posted an answer about multithreading issues on StackOverflow.com which reminded me a lot about a BorCon session he did.
That session is called “Reading Tea Leaves: The Fine Art of Debugging“, it is still very current (a lot of it is not Delphi specific at all: it can be applied to a broad range of platforms), and I was glad to find that Joe White made some great notes and posted them on his blog.

Edit 20100513T0830:  (thanks Mario!) Don’t you love 404 :-)
The blog from Joe White seem to be down, and the web archive of his blog didn’t have that particular page, but the google cache has.

–jeroen

PS:
Danny is a great writer; I’m really glad he showed up at StackOverflow.
Here is another very nice answer from him on concurrency in software using read-write, locking, interlocked increment and more.

Posted in Debugging, Delphi, Development, Software Development | 3 Comments »

Why SizeOf for character arrays is evil: stackoverflow question “Why does this code fail in D2010, but not D7?”

Posted by jpluimers on 2010/05/11

This Why does this code fail in D2010, but not D7 question on stackoverflow once again shows that SizeOf on character arrays usualy is evil.

My point in this posting is that you should always try to write code that is semantically correct.

By writing semantically correct code, you have a much better chance of surviving a major change like a Unicode port.

The code below is semantically wrong: it worked in Delphi 7 by accident, not by design:
Like many Windows API functions, GetTempPath expects the first parameter (called nBufferLength) number of characters, not the number of bytes. Read the rest of this entry »

Posted in Uncategorized | Leave a Comment »

Disk2vhd – new tool from SysInternals

Posted by jpluimers on 2010/05/10

Recently, SysInternals introduced Disk2vhd.

This is a tool that generates a VHD (virtual hard disk image) from a physical disk.
Even better: it can do this for a running system that is online!
They use volume snapshots (a.k.a. Volume Shadowcopy Service) to do this on-line.

From their site:

Disk2vhd is a utility that creates VHD (Virtual Hard Disk – Microsoft’s Virtual Machine disk format) versions of physical disks for use in Microsoft Virtual PC or Microsoft Hyper-V virtual machines (VMs). The difference between Disk2vhd and other physical-to-virtual tools is that you can run Disk2vhd on a system that’s online. Disk2vhd uses Windows’ Volume Snapshot capability, introduced in Windows XP, to create consistent point-in-time snapshots of the volumes you want to include in a conversion

via Disk2vhd.

Note: Sysinternals now has a Live Share at http://live.sysinternals.com where you can download the most recent versions of their tools.

–jeroen

Posted in Power User | Leave a Comment »

Windows 7: new shortcut keys (windows hotkeys and more)

Posted by jpluimers on 2010/05/06

In the past there were already a lot of shortcuts, including a few including the windows key.

SEO Consultants has a good overview of both lists.

Microsoft has the classic list.

Windows 7 introduced quite a few more, which I’ll list below.
Read the rest of this entry »

Posted in Power User | 5 Comments »

Microsoft: IE9 also favours HTML5 over Flash (IEBlog : HTML5 Video)

Posted by jpluimers on 2010/05/04

Last week, I blogged that we should move away from Flash to HTML5, CSS and JavaScript, commenting on Steve Jobs’ Thoughts on Flash post announcing support for HTML5 including video playback of H.264 encoded video.

In the mean time, the Microsoft Internet Explorer team announced that in IE9 they are going to support HTML5 and that H.264 will be the only supported video encoding standard.

There is a truckload of hardware that supports H.264 decoding acceleration.

So  the movement is from a plethora of video encoding standards into one broadly accepted H.264 standard.
When you look at the combination of support in HTML5/H.264 for all the major browsers, only FireFox has not announced support. This is probably because H.264 is not a free (as in beer) standard: commercial use requires payment. But  - if I read the H.264 article right – content that is free for end users requires no royalties to be paid.

This combined hardware and software support means that there is a pretty strong backing for H.264!

–jeroen

Reference: IEBlog : HTML5 Video.

Posted in CSS, Development, HTML, HTML5, JavaScript, Software Development, Web Development | Leave a Comment »

WhiteHouse.gov releases part of their code as Open Source

Posted by jpluimers on 2010/05/03

I just noticed that WhiteHouse.gov last week released some of their code as Open Source.

In addition to using the Open Source Drupal project, they actually contribute to the Open Source community as well.

–jeroen

Posted in Development, Software Development, Web Development | Leave a Comment »

Scott Adams Blog: That Lost 4G Phone 04/26/2010

Posted by jpluimers on 2010/05/03

Scott Adams blogged about the lost 4G phone; the blog includes two drafts of comics that will never get themselves into the Dilbert comic pipeline.

Fun nonetheless.

–jeroen

Posted in Geeky | Leave a Comment »

10 tips for getting rid of stubborn malware | News | TechRadar UK

Posted by jpluimers on 2010/05/02

It is easy – even for experienced power users – to get your PC infected by a virus, trojan horse or other form of malware.

These 10 tips for getting rid of stubborn malware from TechRadar UK should help you getting back on track.

–jeroen

Posted in Power User | Leave a Comment »

 
Follow

Get every new post delivered to your Inbox.

Join 366 other followers