Windows 8 Annoyance

December 5, 2012 Leave a comment

1. Forcing a Production device to be a Consumption one

iPads, iPhones, Androids are consumption devices. It is used to browse internet, play games, write simple emails, and open apps. These consumption tasks usually grabs users full attention one at a time. Engagement is usually short. These tasks require minimal use of multitasking.

On the other hand, Windows PC and iMacs are production devices. Users do homeworks, edit videos, write codes, write long emails out from these devices. It intensively uses keyboard. Engagement spans for several hours. Multitasking is definitely required.

The new iMac is thin that it resembles a giant iPad. But Apple did not choose to run iOS on it. It is a shame overkill to have such big screen for mere consumption. However, this is what Windows 8 exactly is doing. I have a 15.6″ touchscreen laptop, yet this metro-UI just keeps popping up in-your-face apps that waste screen real estate. I can not watch webminars and type-in notes in MSWord at the same time, because Windows 8 Media Player keeps going full screen in Metro mode.

I understand Metro-UI is for consumption use, but I simply just want to do my productive tasks done. The design of forcing users to keep going Metro makes me want to switch back to Windows 7.

2. No folder on Metro-UI

Right out of the box, the Metro-UI already look cluttered. Tight rectangle icons everywhere. I cannot make folder groups to hide certain icons. iOS allows this since iOS 4.

3. Not-so-obvious search bar on Windows Marketplace

To search for Apps in Marketplace, I was expecting a Search bar. But after scrolling right multiple times I could not find it. Turns out, it is hijacking the “Find” text field in Charm Bar. All of a sudden this field behaves differently. Instead of searching on my computer, it now searches the Marketplace.

4. The design decision to remove Start button

Microsoft wants to forcefully reeducate its customer base by removing the Start button. Why not simply relabeling it to something else ? Currently the open source project “Classic Shell” gets this concept right. The Start button should lead to two modes, “Program” and “App”. I know immediately what it means without thinking.

I am hoping that future Windows 8 service packs will address these issues. In short,

  • For consumption device, Windows 8 do a mediocre job compare to iOS.
  • For production device, Windows 8 do a poor job compare to Windows 7.
Categories: Other

IIS Troubleshooting

IIS Troubleshooting

My IIS could not start. Turns out, it is because there is another Microsoft service occupying port 80. It is called “Web Deployment Agent Service” (“C:\Program Files\IIS\Microsoft Web Deploy\MsDepSvc.exe” -runService:MsDepSvc).

This URL link tells me how to get the occupying service, basically by running two command lines.

> netstat -anop TCP|find “:80 “
> tasklist /SVC /FI “PID eq 448”

Categories: Other Tags:

C# – Override vs New

February 17, 2012 Leave a comment

MSDN has an excellent explanation of when to use override and when to use new.

In short:
1. Override guarantees calling the child (derived) method. New does not.
2. Override always needs to be used with keyword virtual. New does not.
3. Overriding on class member requires child type to match the parent type. New does not.
Otherwise it will show the following error:
'SomeChildClass.VarA': type must be 'Parent' to match overridden member 'SomeParentClass.VarA'

Bottomline, if you need certainty, use override. If you need flexibility, use new.

I prefer override instead, for predictability sake…

PS: virtual = override-able

Categories: C#

Visual Studio 2010 build leakage bug

Since its SP1 “updates”, VS2010 has a file lock leakage when building. This cause an error when I am trying to build again. I have to close it, and reopen it again.

Its been over 4 months and Microsoft has not released a patch yet. However, Stack Overflow has documented a workaround.

Write a simple console application to delete the file first or rename it if it fails. Then, call this console application on the Prebuild event.

Line for the Pre-build event: (documented from StackOverflow solution)
“C:\MyBin\VisualStudioLockWorkaround.exe” “$(TargetPath)” (replacing MyBin with the location you place the executable).

Code for Console Application
using System;
using System.IO;

namespace VS2010LockWorkaround
class Program
static void Main(string[] args)
string file = args[0];
string fileName = Path.GetFileName(file);
string directory = Path.GetDirectoryName(args[0]);
if (!Directory.Exists(directory)) //If we don’t have a folder, nothing to do.
Console.WriteLine(String.Format(“Folder {0} not found. Exiting.”, directory));
if (!File.Exists(file)) //If the offending executable is missing, no reason to remove the locked files.
Console.WriteLine(String.Format(“File {0} not found. Exiting.”, file));
foreach (string lockedFile in Directory.EnumerateFiles(directory, “*.locked”))
try //We know IOExceptions will occur due to the locking bug.
catch (IOException)
//Nothing to do, just absorbing the IO error.
catch (UnauthorizedAccessException)
//Nothing to do, just absorbing the IO error.

//Rename the executable to a .locked
File.Move(file, Path.Combine(directory, String.Format(“{0}.{1:ddmmyyhhmmss}.locked”, fileName, DateTime.Now)));

Categories: C#

C# – Event Subscription – with new keyword vs without

Per MSDN here, Event Subscription with new keyword and without are the same.
The one with new was introduced in C# 1.0. It then gets simplified in C# 2.0.

C#1.0: pub.OnCustomEvent += new CustomEventHandler(HandleCustomEvent);

C#2.0: pub.OnCustomEvent += HandleCustomEvent;


Excerpt from MSDN:

2. Use the addition assignment operator (+=) to attach your event handler to the event. In the following example, assume that an object named publisher has an event named RaiseCustomEvent. Note that the subscriber class needs a reference to the publisher class in order to subscribe to its events.

publisher.RaiseCustomEvent += HandleCustomEvent;

Note that the above syntax is new in C# 2.0. It is exactly equivalent to the C# 1.0 syntax in which the encapsulating delegate must be explicitly created using the new keyword:

publisher.RaiseCustomEvent += new CustomEventHandler(HandleCustomEvent);


End excerpt

Categories: C#

C# – How to make VS2010 look and feel like VS2008

For those who do not like the feel of VS2010, we are sharing the same shoes!
Even after SP1 install, VS2010 still feels sluggish, and it looks so Eclipse-like.

After performing these 3 tweaks below, my VS2010 now look like this. 😀

VS2010 with VS2008 look

Here they are:

Tweak #1 – IDE Performance
In Tools> Options > Environment > General
– Uncheck “Automatically adjust visual experience based on client performance”.
– Uncheck “Enable rich client visual experience”
– Uncheck “Use hardware graphics acceleration if available”

There are other tweaks discussed in this thread. But this one step is enough for me.

Tweak #2 – Color Theme
In Tools > Extension Manager
– Search for an Extension called “Visual Studio Color Theme Editor” in online gallery.
– Install it. Go with Theme > Windows Classic
– This should take care of the hideous purple skin color
As discussed in this thread.

Tweak #3 – Change the form icon.
The idea is to replace the embedded purple icon in VS2010’s devenv.exe to the VS2008 one. There are various ways, but here is what I did:
– Use IconChanger from Shellabs here. Trial version should suffice.
– Locate VS2010 devenv.exe file. By default it is in
“C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE\devenv.exe”.
– Replace its embedded icon with VS2008 one. By default it is in
“C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\devenv.exe”.

IconChanger screenshot

IconChanger screenshot from Shellabs

This third step makes that gloomy VS2010 ribbon goes away from your top-left screen, replaced with the sunny VS2008 ribbon.

That’s it! Hope you have a sunny coding day.

Categories: C#

C# – Concise AsyncCallback

The has a concise C# snippets on how to use AsyncCallback feature.

I made it less concise by adding some Thread.Sleep functionality .

using System;

using System.Runtime.Remoting.Messaging;

using System.Threading;


namespace IAsyncCallbackConsoleDemo


    class Program


        private delegate int MyDelegate(string s);

        static void Main(string[] args)


            MyDelegate X = new MyDelegate(DoSomething);

            AsyncCallback cb = new AsyncCallback(DoCallback);

            IAsyncResult ar = X.BeginInvoke("Hello", cb, null);


            Console.WriteLine("{0}-another thread"

                             , Thread.CurrentThread.ManagedThreadId);

            Console.WriteLine("Press any key to continue");



        private static int DoSomething(string s)


            for (int i = 0; i < 5; ++i)



                                 , Thread.CurrentThread.ManagedThreadId

                                 , i);



            return 999;



        private static void DoCallback(IAsyncResult ar)


            MyDelegate X = (MyDelegate)((AsyncResult)ar).AsyncDelegate;



                             , Thread.CurrentThread.ManagedThreadId);




Love ’em concise demos!

Categories: C#