Search...

26 June 2013

Visual Studio - Disable #Region Block Generated When Implementing An Interface

One of the things I have found really annoying when coding in Visual Studio is the fact that when implementing an interface, the editor will wrap the method calls in a #region/#endregion block. So today I was determined to find out how to get rid of them.

It is actually really easy and all you have to do is :

  • Open the TOOLS menu.
  • Select Options...
  • Select the Text Editor option.
  • Select your target language (mine is C#).
  • Select the Advanced node.
  • Deselect the "Surround generated code with #region" option.
  • Click OK

Annoying problem goes away!

19 February 2013

Installing Visual Studio 2012 Update 1. Failures & a possible solution.

Having installed Visual Studio 2012 about a month ago, I finally got around to wanting to do some serious coding with it. Attempting to run my test's I found a message in the Output window that reported an exception had been thrown and that test discovery mechanism had failed. Having a quick Google about I found a lot of people reporting the issue with Visual Studio 2012 Professional if Update 1 was not installed.

So I headed into Visual Studio 2012 and downloaded the Update and fired it off expecting it to be a 10 minute install with no issues.

The first install attempt failed. It didn't give me much to go on except the install log and a link to some Microsoft Tips and Solutions page (which no longer appears to exist). So I tried to repair it. That also failed!

So I removed the update and rebooted and downloaded another copy direct from Microsoft in case there were any issues with the first .exe. I installed again, it failed again. So this time I tried to repair the Update (from the Updates own installer). It failed.

Although it failed, this time I go more information, it had failed when it got to the Visual Studio JavaScript Extensions for Windows Library. After some more serious Googling about I found a post that, on a related subject, suggested downloading the library direct from Microsoft. This I did and I run the Updates Repair option again.

It failed again! There was a serious patten forming here however, this time it complained about Web Deploy 3 already being installed. So I removed Web Deploy 3 and ran the Repair option again and it worked!

So far my overall experience of Visual Studio 2012 is not that great. I had issues installing Visual Studio 2012 in the first place (on Windows 7) and now I have wasted a couple of hours trying to install Update 1.

21 January 2013

Slow Chrome & Firefox Debugging on Windows 7.

These days I live in web browsers and all of my day to day work is browser based. Since I moved to Windows 7 I have had an issue where by Chrome and Firefox would take ages to connect to my local IIS instance. After suffering this for some time I decided to get to the bottom of it.

As it turns out (and there are a lot of false claim on Google!) it is as simple as ensuring you have 127.0.0.1 localhost uncommented in your hosts file. The hosts file can be found in \Windows\System32\drivers\etc. It would appear that if you use host headers for local development work then without this uncommented you are hitting the public DNS servers from what I can tell.

I should add that I am not running IPv6 and so did not enable ::1 localhost but you should if you are running on an IPv6 enabled network.

14 January 2013

Installing Visual Studio 2012 (Windows 7)

Some things in life should be as simple but aren't! After years of installing various versions of Visual Studio you would think I would be prepared for battle but Visual Studio 2012 still managed to get me!

tl;dr Use this iso file to install Visual Studio 2012 Pro, the web installer doesn't work!

(As a side note, I long for the day where installing something on Windows is as easy as it is on *nix. I can install a whole operating system and associated programs in the time it takes to install Office! Alas, that is a separate post!)

Being a modern kind of guy I opted to try and install Visual Studio 2012 Pro via the web installer. I have a decent internet connection and was not expecting a 2 hour install. I was even more disgruntled when it failed! It apparently had not managed to install the Javascript or Sql 2012 tools packages. Reading the ever interesting log files provided no useful (translate : Google'able) info and so I tried to repair the installation. That also failed only this time with a longer list of failed packages.

I then decided I would try a clean install using the old fashioned iso provided by Microsoft. I tried to uninstall Visual Studio 2012 and .... it failed! (I can see a patten forming here.) I tried various things and finally after three tries managed to uninstall it. By try various things I mean I rebooted, I tried to kill various processes that looked like the installer was orphaning and clearing out %temp%.

I then installed this iso file (via the excellent daemon-tools). Forty minutes and another coffee later and it worked and installed.

You would think that in this day and age the web installer would be fail safe. It should know what packages you need download them and install them in a fast and successful manner. Come on Microsoft, it's not hard!

13 December 2012

A Simple Bash open() function That Is Platform Independent.

I use Bash as my shell of choice. This is partly laziness, I learnt Bash first and it has always been the default on clean installs, and also because if I end up on a server or a machine that has just been set up I know what I am doing and don't miss fancy functionality provided by other shells. That's not to say that on my To Do list for 2013 is to learn more about zsh.

One of the tasks I have been trying to do over the last couple of months is tame my dot-files. In doing this I have been trying to clean up functions that I have added to my .bashrc and make them more machine/platform independent. (Once I have done this I will write up how I have structured my dot-files and point you to my GitHub repo).

One of my more frequently used functions is open(). I use Bash extensively on Windows via Cygwin as well as on *nix machines. The aim of the function I started out with was to allow me to open files directly from Cygwin's Bash shell that were standard Windows files (such as Word and Excel files). Since I got in the habit of using the function on Windows I wanted something that worked the same on Linux. Below is the (very) simple function I ended up with

 1 function open()
 2 {
 3     UNAME=`uname`
 4     OSLINUX="Linux"
 5     OSCYGWIN="CYGWIN_NT-6.1-WOW64"
 6 
 7     if [ "$UNAME" = "$OSLINUX" ]; then
 8         if [ "$1" = "" ]; then
 9             echo "open Failed, No file specified to open."
10         else
11             xdg-open "$1"
12         fi
13     elif [ "$UNAME" = "$OSCYGWIN" ]; then
14         if [ "$1" = "" ]; then
15             NATIVE_PATH="."
16         else
17             NATIVE_PATH="$1"
18         fi
19 
20         WIN_PATH=`cygpath -w -a "${NATIVE_PATH}"`
21         cmd /C start "" "$WIN_PATH"
22     fi
23 }

I am sure that the function will be cleaned up some more and made simpler however, it works as I need it to in the 5 mins I worked on it.

The function use's xdg-open which is desktop independent on Linux so it should "just work" otherwise on Cygwin it just uses 'cygpath' to generate the correct file path before using 'cmd' to launch the path.

Please Note :: The path provided to cmd is hard coded to my C:\ drive. I have long given up on using partitioned Windows disks so I took the lazy route here.

Once added to your .bashrc you can just call $open file or $open . or $open ../ to open a file or open the File Manager in the current directory or parent directory.

25 October 2012

Internet Explorer JavaScript - Changing An Elements Type.

Note to Self : When attempting to change an elements type attribute in JavaScript use the setAttribute() function as it is the only way to do it that works with Internet Explorer.

Note to Browser Developers : Please standardise this stuff as it takes too much time to achieve simple solutions!

3 October 2012

Powershell XML Configuration Files.

Recently I have been playing with Powershell and while I still prefer Bash as a shell (long time user) I was impressed with the amount that can be achieved with Powershell.

One of the things that I was looking at doing was automating our build process as we had hit a css file count limit in Internet Explorer (31). I should point out that our css is not that badly laid out but we load specific css files dynamically based on the client's needs. So my aim was to minify our css with the Ajax Minifer tool which can be found on Codeplex. The only issue with our current development set up is that my co-developer hosts his svn working directories on a different drive to mine so I needed to provide a configuration file to specify the path to Ajax Minifer and our code.

Turns our this is really easy in Powershell as it can natively parse XML and provides a nice tree structure to use. The following reads, parses and provides the XML configuration file as said tree :

# read the local config file for various settings ...
$cfgFile = "$PATH_TO_FILE"
$root = "$NAME_OF_ROOT_NODE"
$cfg = [xml](gc $cfgFile)

At this point you have access to the child nodes through $cfg. For example $cfg.$root.EnableDebugging -eq "True" returns the value of the <EnableDebugging> child node and check's whether it's value is set to True.

As with all scripting and shells there appears to be more than one way to achieve this but it works perfectly for what I needed.

20 September 2012

Passing Arrays Between Contexts In Javascript

Today I have found a nasty gotcha that stumped me for some time while creating a snippet of JavaScript which called a function that included an Array as a parameter.

I was trying to call a function on an object bound to the window which contains some utility classes. I created my Array, populated the values and sent it to the function. However, it didn't work as expected. After some head scratching and debugging in Chrome I found that the receiving code was not seeing the Array parameter as an instance of Array. Instead it was seeing it as an object.

After checking my calling code to ensure I was not having a daft moment, and after much trial and error I hit Google. The answer was actually rather obvious once I found it. The problem I was having was that the calling code was in an iframe in my page. When you create an Array you are actually creating a window.Array object. This of course means that the object's prototype is not available to in the window context (i.e. the parent page) and so the receiving function was treating it as an object.

The answer, as I realised while talking to my co-developer, was that in order for the parameter to be seen in the receiving code as an Array, it needed to be declared as new parent.Array(). Once this change was made everything worked as expected.

20 August 2012

Ruby on Rails Arch Linux Basic Instal

I have been playing with Ruby on Rails for a while after completing a Coursera based SaaS course recently. While undertaking the course I worked on an Ubuntu VM which was provided by the course. However, as in all things I hack around with on Linux I really wanted to set up a basic Rails development environment on my main Arch Linux machine.

While the guide on the Arch wiki was fine when I reached the point of testing my environment I got the following output in bash ....

/usr/lib/ruby/gems/1.9.1/gems/execjs-1.4.0/lib/execjs/runtimes.rb:51:in `autodetect': Could not find a JavaScript runtime. See https://github.com/sstephenson/execjs for a list of available runtimes.

A quick hunt around the forums did not help me!

Following the link in the above error message I read up on execjs and found that you need a supported runtime. I opted for therubyracer, an implementation of the Google v8 javascript runtime.

In bash I ran gem install therubyracer which installed the runtime. I then added the following line to my test applications Gemfile :

gem 'therubyracer', :require => 'v8'

Running rails server now served up my test app on the default port (using WEBrick).

8 August 2012

Arch Linux glibc Update

Arch Linux has made a rather big change to the file system recently and has moved the files in the /lib directory to the /usr/lib directory and /lib is now a symlink to usr/lib. You can get an overview of the change here and here. Both of these pages give instructions and possible issue resolutions for most case's.

However, as searching the Arch Forums on glibc will show, the resolutions outlined in the above documents do not always work. There are a large number of users that have had problems due to various files that are left in the /lib directory. To quote Zamboniman from the Arch Forums "This has been one of the more frustrating upgrades in my history with Arch." After running pacman -Syu recently I discovered I was one of these people!

I have now resolved my issue and wanted to detail it incase it is any help to anyone else still struggling with the issue. For a little background I am running Arch 64bit.

NOTE DO NOT USE --force WITH pacman IN ANY FORM TO RESOLVE THIS ISSUE AND DO NOT DELETE OR MOVE ANY FILES MANUALLY.

First, I followed the recommended update method and ran pacman -Syy and then pacman -Syu --ignore glibc. This brought the system up to date and I then ran pacman -Su which will update glibc. However, like so many others, I got the following error output :

error: failed to commit transaction (conflicting files) glibc: /lib exists in filesystem

This, apparently, is caused by files remaining in the /lib directory. As per a number of the suggested solutions I then ran find /lib -exec pacman -Qo -- {} + which lists who owns the files left in the /lib directory. As recommended in one forum post I started to look for files not owned by glibc. There was one file and that was lib32-glibc. A lot of the solutions suggested at this point to just delete the file or uninstall the program that it is installed by however, looking at the file version (2.15-10) I noticed that there was a newer version available. The file is installed from the Multilib repository and I was at a loss as to how it was not being updated. After a little more digging I found that the Multilib repository was commented out in the /etc/pacman.conf file. I uncommented the repository entry in the file and ran pacman -Syy and then pacman -Syu --ignore glibc and then ran pacman -Su.

This all appeared to work. As a final check I ran ls -ld /lib which should output lrwxrwxrwx 1 root root 7 Jul 7 11:09 /lib -> usr/lib which denotes that everything has worked.

This solution will probably not fix everyone's issue with regard to this update and the links below are to forum threads that helped me track down the solution to my problem

  • https://bbs.archlinux.org/viewtopic.php?id=145006&p=1
  • https://wiki.archlinux.org/index.php/DeveloperWiki:usrlib
  • https://bbs.archlinux.org/viewtopic.php?pid=1129890 - This thread contains Zamboniman's excellent advice which appears to have helped a number of people with slightly different issues to mine.
  • https://bbs.archlinux.org/viewtopic.php?id=109765 - Multilib related.
Now, to get on with playing with KDE 4.9!

23 May 2012

Visual Studio 2012 Missing Project Templates

Since I set up my new work machine I have been working on existing projects. However, today I wanted to start work on a little utility application and so fired up Visual Studio. On clicking new project I found I had no templates installed by default.

After some digging on the interweb I found the answer is to close Visual Studio and then navigate to your Visual Studio install directory (c:\Program Files\Microsoft Visual Studio 10.0\) and then locate the devenv.exe. For me the full path was c:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE.

Once there in a Visual Studio Command Prompt you need to run the following :

devenv /installvstemplates

It will take a couple of minutes to finish but once done you can fire up Visual Studio and all the default templates will be available.

16 April 2012

Arch Linux Qt Package Issue (KDE)

For the first time in all the time I have been using Arch I have experience my first major package breakage.

The night before last I ran pacman -Syu and one the packages upgraded was the Qt package. It was upgraded to qt-4.8.1-2. Next time I booted up I was getting a KDE Crash dialog appear noting an error with KRunner. Trying to run krunner from the shell I was presented with a host of errors.

A quick search of the Arch forums I found this post reporting similar problems. Following the advice in the post I downgraded the Qt package and my problems where resolved.

To find out if you can downgrade your package you will need to search the /var/cache/pacman/pkg directory to ensure you have a package to downgrade to. If you do then you can run pacman -U /var/cache/pacman/pkg/qt-4.8.0-6-x86_64.pkg.tar.xz (or whatever version you have). If you can not find an earlier package in your cache then you will have to refer here (the Arch wiki) which will provide further details.

(I should mention that I am running 64bit although I have no idea if this effects 32bit).

15 April 2012

KDE 4.8 Task Manager Launcher Issue.

Of all the great new things that arrived in KDE 4.8 one of the most annoying to me was the inclusion of a browser and file manager launcher in the Task Manager. These are the little icons that appear when the said application is not running.

I tried to remove the launchers with the usual right mouse menu option but everytime I re-booted I ended up with the icons back again.

I have finally figured it out though. For some reason you need to remove the Task Manager from the panel and add a new instance of Task Manager and that seems to solve the problem.

While it is a 2 minute fix it is something that should just work by default I think.

22 March 2012

Arch Linux - i3 Graphics Setup

Gonzo has been reborn!

My trusty old Thinkpad has finally died and so I have brought a Fujitsu A531 to replace it. Its not a bad spec for the money I paid (i3 2.2, 8gb, 750gb HDD all for £419).

I have just installed Arch 64 bit on it and had KDE up and running in less than an hour and a half. The first thing I noticed was the graphics acceleration was not enabled and I seemed to be suffering poor framerates. I found that by adding a file called 20-intel.conf to the /etc/X11/xorg.conf.d directory and adding the following solved my issues :


Section "Device"
Identifier "Card0"
Driver "intel"
Option "DRI" "true"
Option "SwapbuffersWait" "false"
EndSection


Reboot and 3D effects and a good framerate where restored.

28 February 2012

Skype & IIS Clash.

As I am working completely remotely these days I have found my use of Skype increase. This is mainly for chatting to my co-dev throughout the day. Not being a massive Skype fan I actually have it configured for use through Trillian which is quite a good multi-protocol IM client.

Today while mid call with my co-dev I found my Firefox instance hanging and so did an iisreset on my local dev box. Killed Firefox and attempted to start debugging again. Only Visual Studio didn't want to play ball. It showed an error dialog with the following message :

Unable to start debugging on the web server. The server committed a protocol violation. Section=ResponseStatusLine.

OK, that was a new one to me! I started to dig about and found that the caused of the problem was Skype. It appears that Skype will try and use ports 80 and 443 as optional ports to connect on. This meant that IIS was not able to listen to either of these ports.

I killed Trillian (which in turned killed Skype) and all was resolved and I could debug again.

It appears you can disable the option to listen to these ports in Skype. You need to go to :

Tools -> Options -> Advanced -> Connection

On this option page you need to uncheck "Use port 80 and 443 as alternatives for incoming connections". Restart Skype and you should find you have no more issues.

22 February 2012

Column Editing Mode For Visual Studio & (G)Vim.

I have been a heavy Visual Studio user for 10 + years. I was re-factoring some code today when I found that it has Column Editing capabilities. This was caused by me getting a keyboard short cut wrong and not noticing as I typed. From a quick Google this appears to be something that has been available for sometime. Usually when I need to do Column Editing in bulk I switch to (G)Vim and have often wished it was available in Visual Studio.

To edit columns in Visual Studio you simple have to hold SHIFT+ALT after selecting the start point with your mouse and then drag to select the columns you wish to edit. Start typing and your columns will all receive the edit.

As a side note Column Editing in (G)Vim is very easy. Simply hit CTRL+V to put you into column editing mode and then select the columns to edit. Once selected hit SHIFT+i to put you into insert mode and start making your edits. Once done hit ESC to exit column editing mode.

3 January 2012

SQL Server Express - How Not To Install It!

So new year, new job and new laptop. This is a great way to start the new year.

Working for a new company has meant installing a new Microsoft based development environment, part of which is the freely available SQL Sever Express. Installing it should have been a breeze using the free to download installer (or I believe you can also install using the Web Installer). However, as I had already installed the ASP.Net framework stack it turned into a rather long process.

SQL Express does ship with Management Studio which I think is brilliant considering it's all free! However, when I installed SQL Express there was no option to install Management Studio. I, wrongly, assumed this would just be installed by default. When the install finished I looked for Management Studio but realised it was not installed. After much reading and research I found out that if you install SQL Express as part of the .Net framework installation you are unable to then install Management Studio tools as part of a subsequent instance installation.

That's really not very helpful!

The short version of the rest of the story is that you need to uninstall all instances of SQL server Express and then re install it again. Once you restart the installation you find you have the option to include Management Studio Tools.

Now don't get me started about not being able to change the servers default collation ....

21 December 2011

Google Video Chat Fix

My wife and I tend to communicate through gtalk and recently the video chat. However, a couple of nights ago her laptop stopped allowing her to invite people to video call.

After realising it was something to do with the flash plugin I installed the latest version and applied all of the updates to no avail.

After a little Googling I found the answer to be the following and I thought I would post it here in case it's useful to anyone else.

Basically, go to your GMail account settings and find the Labs tab. Scroll right down to the bottom and there should be a Lab for Video Chat Enhancements. Click "Enable" for that lab and then save your settings. It worked a treat and she is now back up and running.

This issue seemed to effect both Chrome and Firefox although other people I have read about only seem to be effected if you use Chrome. Either way that solve her problem.

4 October 2011

Arch Linux - LibreOffice Displaying Non English

When LibreOffice was first released I instantly installed it (via pacman) on Arch Linux. Having read lots about the grand work the project was doing to finally bring the project upto date since forking Open Office I was interested to see what they had achieved. I was quite impressed.

I don't do a lot of document based work on my Arch laptop (and there have been a number of updates since I last used it) but I went to type up a letter for the wife tonight and fired up LibreOffice and found the UI was rendering in what appeared to be Russian (which I do not read or write).

After a bit of digging about it appeared I made a fatal error in installing the libreoffice-uk language pack. Turns out that is the Ukrainian language pack ... oops!

It turns out that I am not alone in making this assumption and if you happen to hit this issue and you actually need English and not Ukrainian then install the libreoffice-en-GB language pack and all will be well (and readable) again.

9 August 2011

Visual Studion 2010 Debugging Time Out.

One thing that has started to bother me since going to a VS 2010/IIS7 setup is that by default the time-out on the debugger is incredible short. You start looking into a problem and be on the point of realisation when a Message Box pops up saying that the thread is aborting.

Helpful, that is not.

After a little digging about I found that it has something to do with the application pool settings in IIS. To increase the time the thread is available open IIS Manager, open the application pool your site is running on and click "Advanced Settings". In the property dialog that comes up there is an item labelled "Ping Maximum Response Time (seconds)". Set this value to your desired value and click OK.

I have mine now set to 6000 which should be enough for now.