Node.js has released an exe version that can be run on Windows to execute JavaScript on the server. The current version is 0.5.2. On the internet there are various articles on what Node.js is and how to use it.

Microsoft has recently partnered with Joyent to get Node.js running on Windows. Maybe in the future to run on the Microsoft Azure platform (My speculation).

To get started head over to the Node.js site and download the exe. Create an directory to put the exe.

Folder Directory

Create a folder next to the exe for you first Node.js project like Hello. Inside the Hello folder you create an server.js file to create your first web server application.

Here is an very basic example

Server Code

To run the Node.js example open up PowerShell and run the following command:

.\node.exe .\Hello\server.js

Run in Powershell

Now open your favourite browser and browse to the URL you specified in the source file.

Browser Display

That is it! Your first Node.js application running from Windows. Very easy.

Here are some additional links to read:

http://nodebeginner.org/

http://howtonode.org/

http://nodeguide.com/

https://github.com/joyent/node/wiki/

I will later follow up with a full blow HTML application.

Cheerio!

Here are a couple of tips and tricks for Oracle VirtualBox. At the time of writing this blog the latest version of VirtualBox is 4.1. The VirtualBox commands that follow is run in Windows but is more or less the same in Linux environments.

Tip 1 – Clone existing Virtual disk

In command line go to the path of where VirtualBox is installed because you are going to need access to the program VBoxManage. Windows command to change path: cd "C:\Program Files\Oracle\VirtualBox"

Command to clone an existing vdi file:

VBoxManage clonehd "path_to_source_image.vdi" "path_to_destination_image.vdi"

From version 4.1 there is an menu option to clone existing images in the VirtualBox Manager GUI.

Tip 2 – Clone existing Virtual disk to raw format

Cloning an existing image file to raw makes an copy of the image without any compression to the vdi format.

Command to clone to raw file:

VBoxManage clonehd --format RAW “path_to_source_image.vdi” “path_to_destination_image.raw”

Tip 3 – Convert raw image to vdi format

If you have an raw image you can convert it to the compressed vdi file format.

Command to convert from raw to vdi:

VBoxManage convertfromraw --format VDI “path_to_source_image.vdi” “path_to_destination_image.raw”

Tip 4 – Recompress an vdi file

After using an image file for an while it will keep allocating disk space if dynamic allocation is used, but you can reclaim some of that used disk space.

Inside the image you need to remove unused data and use an tool like CCleaner in Windows images to clear temp files.

Then you need to defrag the hard drive inside the image. Do defrag the hard drive twice. I use the tool Defraggler which is much better that the default defrag tool of Windows.

After that you can use the CCleaner drive wipe tool to clear free space only or use an similar tool. This will replace all clear space with 0 bits.

After that shutdown the image file and run the following command to recompress the vdi file: VboxManage modifyhd “path_to_target_image.vdi” compact

This command will remove all those 0 bits from the image file. After running the above command you will see that your vdi disk allocation has reduced. I have successfully shrink an vdi file from 70GB to 41GB.

Tip 5 – Host VMWare images

Firstly on you host you need to uninstall all VMWare tools.

Inside VirtualBox mount the VMWare image (.vmdk file) as an IDE, not SATA (the default when using the VirtualBox wizard).

Make sure the .vmdk filename does not contain '.' suffices.

After that you should be able to run the virtual disk.

 

Hope all these tips help you to run VirtualBox more efficiently and make you life easier. If you use any other VirtualBox command regularly let me know!

Cheerio!

I had the pleasure of presenting at the SA Dev workshop on 27 July 2011.Thanks to everyone who attended and please continue to support the local communities.

My discussion was based on Web application UI testing with open source tools and Visual Studio Testing tools. More specific I was covering AutoTest.Net for C# unit testing, QUnit for JavaScript testing and Web Tests and Load Tests in Visual Studio 2010.

Here is the links to my slides and demo application:

Web UI Testing Slides

World of Football Demo Application

Any feedback is welcome and thanks again!

Cheerio!

I recently worked on a project where I developed an WCF web services that is exposed via  https and net.tcp. The web services does all the database calls and business logic. Here are some lessons or tips for developing in WCF with net.tcp.

When I use the net.tcp channel to communicate to the web service I often get the following error:

The socket connection was aborted. This could be caused by an error processing your message or a receive timeout being exceeded by the remote host, or an underlying network resource issue. Local socket timeout was '00:01:00'.

This is the default error message that you will get from WCF if something went wrong but the WCF channel does not know exactly what error occurred.

What to do when you receive this message.

  1. Increase the ReceiveTimeout and SendTimeout on the binding that is used by your web service to 5 min. The other timeout properties default values are 99.9% always correct. The 5 min is very big and will usually eliminate actual timeout issues.
  2. The usual suspects for the error is MaxBufferSize, MaxBufferPoolSize, MaxReceivedMessageSize, MaxArrayLength default size (65536) is to small. Increase them by adding a 0 at the end (655360) to see if the error disappear. Then by small increments reduce the size to find the correct value.
  3. If your web service method returns an big message or generic array or list with a big items count and big object graph you have to increase the value of the property MaxItemsInObjectGraph in the dataContractSerializer element. You need to create a Service Behaviour (Service side) and Endpoint Behaviour (Client side) with the dataContractSerializer element. You will then see the MaxItemsInObjectGraph property.
  4. To increase your communication between service and client you can switch the TransferMode in the binding from Buffered to Streamed.
  5. When you call the web service from an .Net client please avoid calling your code inside a using statement. Rather use try-finally where you can call close on the client object and if the communication channel faulted you can call abort on the client object.

These lessons will hopefully make your net.tcp development experience easier. If you have any further tips or lessons please leave a comment.

Cheerio!

Here is my talk that I presented at Devs4Devs. Thanks to Microsoft for the opportunity and thanks to the guys who attended.

At the bottom is the links to my presentation and sample code. Before you can use the sample you need to setup Windows Server AppFabric Cache and use the AdventureWorks Database.

Another note that the web service gets deployed to IIS when you build the project.

Here the links:

AdventureWorks Database

http://msftdbprodsamples.codeplex.com/

Sample Application

http://dl.dropbox.com/u/4406115/Devs4Devs%202011/AdventureService.zip

Presentation Slides

http://dl.dropbox.com/u/4406115/Devs4Devs%202011/WCF%20AppFabric%20Cache.pptx

Any feedback or questions are welcomed. Until the next talk!

I was busy going through some SQL Adapter walkthroughs in BizTalk 2010 and something very strange happened.

I was setting up my SQL Adapter, not the WCF SQL Adapter, and I come to the wizard screen where I need to select between Select or Stored procedure options.

I happily decided on the Select option. In the next screen you get a text area to write your SQL statement. Mine was just a simple select from a small table. I click the Next button and bang the whole wizard dialog disappeared. No SQLService.xsd was generated. I was so confused and though I did something wrong. I went over the steps like a crazy man.

Finally I restarted Visual Studio 2010 IDE and try again. After the restart everything just worked. I still don’t know why this happens. I don’t know if it is Visual Studio IDE or the SQL Adapter Wizard issue.

Lessons Learned – If something goes wrong in Visual Studio IDE for no reason then just restart the IDE and try again!

Cheerio!

With all the controversy about Reflector going commercial. People had to start looking for other solutions. You know that RedGate tools are very expensive.

So, the first tool I want to show you is ILSpy from SharpDevelop. This is a new tool and that means development is in progress. It follow Reflector’s principle of keeping it simple. Here is a screenshot:

ILSpy

ILSpy Features

  • Assembly Browsing
  • IL Disassembly
  • Saving of resources
  • Search for types/methods/properties
  • Hyperlink-based type/method/property navigation
  • Base/Derived types navigation
  • Navigation History

ILSpy Roadmap

  • Improve the decompiler
  • Assembly Lists
  • Find References
  • Improve search performance
  • Save Assembly as C# Project
  • Debugger
  • Bookmarks
  • Extensibility via addins
  • Find Usage (of type/method/property)

The only thing that is short coming is all those nice plugins that Reflector had. I believe the authors of those plug-ins will soon port them over to ILSpy. As soon as ILSpy provide the extensibility via addins. Please download the tool and provide feedback.

On another note if you are using Resharper. In Resharper 6 that is currently under development you will get a decompiler. Go and check out the following article on JetBrains site: Resharper 6 Bundles Decompiler, Free Standalone Tool to Follow

Cheerio!

Disqus