Monday, September 22, 2008

Reinstall of Vista and Ubuntu Virtual Machines

Over the weekend I was trying to install a few things on my Vista and Ubuntu Linux virtual machines. Both are 64bit VM's runing under Server 2008 x64 with Hyper-V. I ended up in the situation where the Vista machine lost its network connection and then wouldn't power down. It got to the point of almost powering down and then hung. I tried all sorts of things to sovle this problem but was unsuccessful. This state of the VM was also causing Server 2008 to blue screen on about every fifth reboot and when I looked at the log files they always related to the VM. I also tried to start and stop the Linux VM (which had been in a stopped state all this time) and the same thing happened inasmuch as I couldn't power it down.

In the end I uninstalled the Hyper-V role in Server 2008 and deleted the VM machines from the hard disk. Here are my notes about what I learned and the mistakes that I made.

  1. Download and get the ISO ready before creating a virtual machine.
  2. When setting up a VM that does not have Integrated Components select a legacy network adapter.
  3. Uncheck the box that says "start VM when this wizard finished" (or somthing like that).
  4. Once you've created the VM open the settings and check them all. Check that there's a single network adapter and that it's a legacy adapter.
  5. As soon as you've run the install of the operating system and it's completed its initial updates take a snapshot of the VM.
  6. Take regular snapshots of the VM after each operation that you perform.

 

Saturday, September 20, 2008

Hyper-V with Vista x64 and Ubuntu Linux Desktop x64

Notes about setting up Vista x64 as a guest virtual machine on my Windows Server 2008 x64 machine.

The installation ran relatively smoothly. I pointed the Hyper-V wizard at the Vista x64 iso and the installation happened.

The only tricky part was getting the network connection up and running. On Hyper-V, under settings for Vista x64 I had to add a Legacy Network Adapter and set that to my point to my Virtual Network. I also left the MAC address at Dynamic and unchecked the "Enable virtual Lan identification" check box.

When setting up Ubuntu Linux Desktop x64 I had to use the same strategy with setting a Legacy adapter to get it to hook onto the network.

I read somewhere that it's the x64 part of these operating systems that cause you to have to use the legacy adapter. I'm right on the edge of my knowledge at the moment as I've never done any of this before so take what you read with a pinch of salt. I now believe that it's because the Integration Components (IC's) are not available for these OS's.

Did Borland throw away the C++ compiler market?

Back in the days of DOS to Windows when the market was about 60% DOS and 40% Windows (early 1990's) Borland was the first to the market (when compared to Microsoft) with a C++ compiler. Shortly after this compiler came out they also brought out 2 libraries. One was called OWL which stood for Object Windows Library and I forget the name of the other but it might have been TF for Turbo Framework. OWL was a library for writing Windows apps and TF was a windowing library for DOS.

During that period a lot of programmers were trying to target both platforms to maximize the number of platforms their software ran on - an obvious goal and is still in practise today. What I thought was crazy was they fact that OWL and TF had completely unrelated API's. In other words, there was no way you could easily target 2 platforms with this compiler. At the time I thought that it was ludicrous and I've never seen a good explanation for it.

A short while later Microsoft brought out the first of its Visual C++ compilers with MFC (Microsoft Foundation Classes) and walked away with the market. MFC never targeted DOS but by then I believe that the PC market share had reached a 50/50 point and it was obvious that DOS was doomed. Had Borland brought out a single API that could target both systems I believe that they would have survived for many more years in that market and may have even been a competitor today.

Friday, September 19, 2008

How Stack Overflow is helping me

Jeff Atwood from Coding Horror has recently moved Stack Overflow to public beta. According to my user profile, as of today I've been using it for 35 days and I've found it amazingly useful.

When you're coding there is often a question that has an easy answer but you don't know the answer off the top of your head and your initial searches on Google don't reveal it. I have found that a well worded question on Stack Overflow will usually yield an answer within a few minutes. More complex and difficult questions sometimes take longer.

This is the equivalent of turning around to your 2 or 3 colleagues who are sitting near to you and saying "hey, how do you create a C# continue statement in Ruby?" except you're saying it to 1,000 compatriots on Stack Overflow.

I'm very impressed.

TIPS:

  1. When asking your question be precise.
  2. Ask a question that has a definite answer that will help you move on to the next problem when answered.
  3. Give (as brief as possible) some background to your problem if relevant. Your language (don't assume that everyone codes in C#), OS, platform.
  4. Return to the question and mark one as correct - if appropriate and also vote up any other answers that were useful.
  5. Thank the people that answered your questions.

Wednesday, September 17, 2008

From power on to a working system

I've just built myself a new computer. It has 8GB of RAM, a fast processor and plenty of fast disk space and is running Server 2008 Enterprise. What I'm doing here is recording how long it takes from power on to windows loading to the sign-on screen. Because the system is new and fresh this time should currently be the shortest time that the computer will ever take to perform this task.

I intend to come back to this post and add more times in the months (years) to come and see how much the system slows time as I add bagage to it.

17 Sep 2008 - power to windows: 30 seconds; windows to logon: 40 seconds (Checked build of Server 2008 - later uninstalled)

On new installation of retail version of Server 2008:

18 Sep 2008 - power to windows: 30 seconds; windows to logon: 27 seconds

Installation failed for component Microsoft .NET Framework 2.0SP1

I'm trying to install .NET 3.5 SP1 onto Server 2008 Enterprise and I'm getting this error:

Microsoft .NET Framework 2.0SP1 (x64) (CBS): [2] Error: Installation failed for component Microsoft .NET Framework 2.0SP1 (x64) (CBS). MSI returned error code 1

On inspection of the folders it appears that .NET 3.0 is already installed C:/Windows/Microsoft.NET/Framework/ here. Mystery still not solved...

Tuesday, September 16, 2008

String Contains From Array with Extension Method

Using LINQ, I wanted to find all lines in a file that didn't have any of the strings in an array of "exclude" strings that I had. This is the function that I came up with to handle that case once I'd read in the lines from the file.

        static string[] NotInSecondArray(string[] first, string[] exclude)
        {
            return first.Where(a => !a.Contains(exclude)).ToArray();
        }

However, the string Contains function doesn't take an array so you need to add something like this:

    public static class MyExtensions
    {
        public static bool Contains(this String str, string[] inArray)
        {
            foreach (string s in inArray)
            {
                if (str.Contains(s))
                {
                    return true;
                }
            }
            return false;
        }
    }