Thursday, December 27, 2007

Vista Sidebar Gadget - Countdown to "2008 Global Launch Wave"

Since our user group will be hosting the Global Launch Wave 2008 I figured it woul be usefull for people to keep track of the launch. Turns out someone has already created a Vista gadget to do just that! It counts down the number of days until the "2008 Global Launch Wave" which will start on wednesday February 27th 2008. Windows Server 2008, Visual Studio 2008 and SQL Server 2008 will then all be launched. Follow the link here

Saturday, November 24, 2007

VS 2008 - Getting Started (Mult-targeting)

So, first things first!! I downloaded the RTM of VS 2008 Profssional iso, burnt it to a DVD and installed. No problems so far on my Vista Desktop :)

So for the next few weeks I'll show you what's new and why you can get onto this new product as soon as possible. I've seen a great session by Daniel Moth at TechEd Developers two weeks ago and so I will be using his tour tips in this series too. I'm telling you if you get a chance to go to any of his sessions, GO! He packs 150mins in 75 mins and sometimes you have to play it back again at half speed :)

So for this first session whats new?!

Firstly Multi-Targeting. What this basically does is allow you to say, hmmm this solution will be based on .NET Framework 2.0, or 3.0 or 3.5. THen what happens is the IDE removes all features not related to the selected target .NET framework. So if you chose 2.0, all the WPF stuff goes away. So perhaps you start with 3.0, and after a time, having used some 3.0 stuff by accident :) you flip back to 2.0? Well the IDE will flag all the 3.0 stuff that will no longer work!! Cool!!!

So this is most definitely the first most important thing you will see, and also a great selling point for you to ask your boss to upgrade and possibly not use VS2005 any more. Since you can still target those apps selectively and work on other projects for 3.5 all with the same great tool.

Tuesday, November 20, 2007

Visual Studio 2008 RTM now available for download

Atleast for MSDN subscribers anyway.

As of yesterday you can now download the following versions from here:

  • VS 2008 Professional
  • VS 2008 Standard
  • VS 2008 Express
  • VS 2008 Team suite and foundation server (Trials)

The rest should be coming soon, atleast before the end of the month, as promised at TechEd Developers 2008 :)

PS Don't forget to turn off your popup blocker or you won't be able to download the files :)

Monday, November 19, 2007

EMEA MCT Community Summit 2008

Well registrations have been open for a few weeks and the number of registrations is staggering. Most people that reserved a seat have now confirmed and we are looking forward to a sellout in Berlin this year. With lots of Developer content this year on VS2008 and SQL2008 I'm sure it's gonna be a great event. If you're an MCT and interested in jumpstarting on these latest MS releases, check out the website for the event here, and register today.

Friday, November 9, 2007

TechEd - Day 5

Well TechEd Developers is now over and I'm exhausted!! IT Forum will be starting this week and I'm sure they are planning some great stuff. I'm quite happy to take back my new htc Touch and my free delegate pass for next year, so all-in-all it's been a great event.

Thursday, November 8, 2007

TechEd - Day 4 part 2

Phew it all over... or is it just beginning....
The finalists were:
Maciej Pilecki
Karl Davies-Barrett
Bill Aryes
Jeff Wharton

The running order was decided on the spot with each contestant drawing a number. I followed up on Maciej's new presentation on SQL UDF's with my WPF in windows forms. I was chilled and relaxed and enjoyed every minute. THe presentation went like a dream and the judges were very favourable. Jeff's SQL RAID talk went really well. His 'Big Daddy' for RAID 10 was a cool touch picked up by the judges, perhaps that's what clinched it.

The Final results were

Jeff Wharton
Karl Davies-Barrett
Maciej Pilecki
Bill Aryes

So Jeff is coming over to speak next year and got 1m of books. I get a free delegate pass and 0.5m of books. So I'm over the moon :)

TechEd - Day 4

Whooooo, I'm in the final!! :) After beating off stiff competition from another MCT from Lebanon I'm presenting my session again in the final in just 30 mins time. I've tweeked it slightly and hope it will give me an edge over the other two MCT finalists. It's not gonna be easy cos they are all really good, but the experience will be worth it. Being a wave 4 winner I should present last which is good and bad.

Wednesday, November 7, 2007

TechEd - Day 3

Great news.... my flat mate Jeff Wharton is thru to the Speaker Idol Finals tomorrow. He gave a great presentation on SQL Server, RAID, and Developers!! Even though the sound was all broken in the begining he kept going. It was amazing to see another Aussie in the running, Brent Shepard, and Michael Howard on the judging Panel, from New Zealand. Naturally it was a great time and every one really enjoyed the show.

Tuesday, November 6, 2007

TechEd - Day 2 (part 2)

I think I've been swagged!!! I was walking through the Community Area when one the the NxtGenUG guys grabs me and say wanna take part in a little quiz show... Swaggidy Swag. I'm like...OK and I sat down in the hot seat!! So the rules are like this. The presenter asks you a question and you have to think of an answer. In the meantime the judges, made up from other TechEd Attendees and Speaker Idol Judges write down what they think you are going to say. If they match you get points. Simple right? Well After 3 rounds, we had only got one point each. Just to give you a sample of the questions..

Visual Studio is good for Developers... Mac is good for Designers... Linux is good for...
Dave has a very large Laptop bag, the other day he pull a .... out of it.

As you can see the questions leave a lot of scope for imagination!!! The winning question for me was: The IT world needs more.... And I said SUPERMODELS!!! Luckly two/three of the judges were on my wavelength.

So what did I win... a bag full of goodies like an Apress book on WF, Virtual Earth Mug, T-Shirts and....... an HTC Touch Smart Phone.

It took me about 2 hours to figure out how to use it, since I never owned a smartphone before, but I do now have an excellent PDA Trainer... Caio Proiete - The PDA Expert. It wasn't long before he showed me the Wifi, Skype on the phone,

TechEd - Day 2

Well today was an amazing day. While I was in the Hands-on-lab in the morning looking after the ASP.NET Exercises, good news arrived .... I was told that due to sound problems on the first day of Speaker Idol and the load background music it was only fair that I was given a second a chance to present my session: Spicing up Windows forms with a little WPF! Well I was over the moon!! So this Thursday I will give it another go against two other MCT's who are also Hands-On-Lab Proctors also.

Thanks a lot to the organises for making this possible, I'm looking forward to it :)

TechEd - Day 1 : Speaker Idol 2007 - First wave

Well I gave a hell of a presentation of WPF controls inside a Winforms to a packed confernece are TechEd Developers BCN tonight. First night, opening reception, first slot. After 3 seconds I calmed down and loved every minute. Unfortunately it was not enough to get me through, I came second to Maciej Pilecki after he gave a talk on SQL server Table variables vs temporary tables. Still the experience was worth every minute. Guess I have an excuse to try again next year!!!

Saturday, October 27, 2007

Toshiba Satellite A200 runniing Windows Vista - Built in Webcam stopped working

Although this had nothing to do with with Microsoft Anytime I was getting the following message:
When you select Start Camera in the Camera Assistant software you may see this error message: "Please turn on the Camera".

After wasting half an hour trying to reinstall the driver, down load the orignal software etc, I stumbled across the soltuion on the Toshiba site:

Re-install the driver for the webcam.

Then Follow these steps to re-install the driver for the webcam.
You will need to be logged in as an Administrator or have an Administrator password ready.

1. Click the Windows Start button.
2. Click Control Panel, System and Maintenance and then Device Manager.
3. Right-click on Chicony USB 2.0 Camera and select Update Driver Software. A yellow exclamation point indicates that the camera is recognized by Windows but is not working properly, probably because of problem with the device driver
4. Select Browse my computer for the driver software.
5. Select Let me pick from a list of device drivers on my computer.
6. Select USB Video Device from the list, and click Next.
7. If the message “Windows encountered a problem installing the driver software for your device” appears, click Close.
8. Restart Windows.

The webcam should now work properly.

Saturday, October 20, 2007

Sync Pocket PC2003 on HP 5450 pda with Vista

I know that ActiveSync cannot be used on Vista to Sync outlook. However if you read the supported OS section of Microsoft Windows Mobile Device Center 6.1 for Windows Vista (32-bit) you'll see that any pocketPC 2003/2 version is not supported.

So there was me thinking of either downgrading my OS back to XP or buying a new PDA!!! Then I came across someone who said, hey just install it anyway, I've been syncing my HP 5455 no problem. So I thought, if he can do can I!! Well the install of WMDM was a breeze and the UI rocks. I held my breath for a while whan I said setup partnership, thinkig here comes the 'your device is too old....' But it worked. It actually worked and now I can sync on Vista with my Outlook on Pocket PC2003. I think there is 1 proviso, the desktop must not be Outlook 2002 or 2003. However on this I am not sure.

So it looks like no new PDA for me.... just yet :)

Friday, October 19, 2007

Speaker Idol 2007 @ TechEd Devlopers Barcelona

YES YES YES, I'm through to being on of the last 9-12 finalists for the Speaker Idol contest at TechEd Developers this year. After recording my 3 minute on How to Spice up your Windows Forms applications with a little WPF session over 20 times, I had the pleasure of recieving an email today say that I'm through to the next round. Whooo :) Just one step before the finals now!!! There will be 3 waves – each wave will host 3-4 participants. The 3 wave winners will then redeliver their presentation to the judges at which stage one overall winner and one runner-up will be selected.

Thursday, October 4, 2007

Joining a Windows Vista Business Desktop Client to Small Business Server 2003

Spent most of today trying to get a Vista desktop to join an SBS 2003 server. Most of the time was wasted trying to get SP2 on the machine which did not seem to be properly installed. This is a pre-requisite to installing the various patchs found here on the SBS 2003 server. This page leads in nicely to all the supported combinations of clients and servers.

Thursday, September 20, 2007

The type 'namespace.ClassName', provided as the Service attribute value in the ServiceHost directive could not be found.

So I'm working through my WCF Step-by-step using my favourite langauge, VB.NET, although the book is written in C#! No VB.NET code here so I have to translate and type, no copy paste for me. Well after carefully crafting an interface as the public part of my service and implementing the interface in a class, I build the svc file just like the book and get

The type 'Products.ProductsServiceImpl', provided as the Service attribute value in the ServiceHost directive could not be found.

I think this is a typo, so I check my namespace, OK, I check the Class that implents the interface and it checks out, so I google a bit and some say, you need the fully qualified name. hmmm So I take of the rootnamespace on the assembly and all is OK. But this is not the way to fix problems, I want my rootnamspace so I decide to alter the svc to look like this:

ServiceHost Service="ProductsService.Products.ProductsServiceImpl"

Looks good but then I get another error:

Service 'ProductsService.Products.ProductsServiceImpl' has zero application (non-infrastructure) endpoints. This might be because no configuration file was found for your application, or because no service element matching the service name could be found in the configuration file, or because no endpoints were defined in the service element.

So lets look in the Web.config, under system.serviceModel section:

service behaviorconfiguration="ProductsBehavior" name="Products.ProductsServiceImpl"
endpoint address="" contract="Products.IProductsService" binding="basicHttpBinding"

Ohhh the servicename and the contract are now wrong:


Ah at last the service is up and running and browsing the svc file in IE7 shows me the link to the WSDL and all is well.

TechEd Developers 2007 BCN

Wow a year has past since the last conference and it looks like I'll be returning to Barcelona this year for THE developer conference in Europe, Microsoft TechEd Developers 2007. I will be attending to the Hands-on-Labs as a Proctor for the duration of the conference as well as taking a shift at the Ask-The-Experts booth, most likely for Visual Studio 2005. Well As things start to develop I'll keep posting the details, but for now it's flights and accomodation that I need to take care of!!

Saturday, September 15, 2007

Multithreading with VB.NET Series - Part 1

So yes we all know that VB can now multithread with so much ease that we can get ourselves into trouble!! Tell m e about it, I was a victim of a naive assumption once which brought a SQL server to a grinding halt after it spawned 700 threads when a user press the damn button 7 times to make sure the 100 transactions went through!! The data was fine but the server was 'crying' for resources. Anyway that's another story...

So to create a new thread to do some work it a POC:

Dim th As New System.Threading.Thread(AddressOf MyLongRunningProc)
' Kick off that new thread to do some work

Private Sub MyLongRunningProc()
' Do the hard work here !!
End Sub

The questions that start to arise as you move into the world or asynchronous programming will soon start to pop up, due to most peoples affinity to synchronous programming mind set. So if two things are happening at once how do I keep track of progress, access shared data in a safe manner, etc. Well here MS has given us so many toys to play with, enter:
1. The Monitor,
2. The Mutex,
3. ReaderWriterLock
4. The Interlocked Type
5. The SyncLock Statement,
6. The Synchronization and MethodImpl Attributes,
7. VolatileRead/Write and MemoryBarrier,
8. The Semaphore Type.

So over the next few posts I will try to demystify so of these terms you may have heard about, but were to too afraid to use them. This should hopefully put some pretty cool tools into you toolbox to help you create those responsive applications you love to give to your clients, but also to make them more robust and safe :)

Wednesday, August 22, 2007

Ever wished you could select a vertical column of code?

Stumbled across this cool shortcut in the VS editor:

Hold down the right CTRL+ALT key and then drag the mouse to select a rectangular column of text....

How to find the system directory (and other environement variables)

Was looking through the msdn Forums recently and someone was asking how to get the system path to save some files... and I though hmm this sounds like a job for the my namespace.... Alas I was wrong, could not help me but then it struck me... The system.enviroment class could help. Here are some of the goodies in this class:

Returns and sets the fully qualified path of the current directory; that is, the directory from which this process starts.

Returns the NetBIOS name of this local computer.

Returns an OperatingSystem object that contains the current platform identifier and version number.

Returns the fully qualified path of the system directory.

Returns the network domain name associated with the current user.

Returns the user name of the person who started the current thread.

Returns a Version object that describes the major, minor, build, and revision numbers of the common language runtime.

Returns the amount of physical memory mapped to the process context.

me.text = System.environment.systemdirectory

Monday, August 20, 2007

Where is SmartNavigation in ASP.NET 2.0 (VS2005)

Had a quick question taday that comes up often so I decided it's time to blog it!! In vs2003 there was this feature that would hold the page position after a postback so that it was redisplayed, updated at the postion where the page was scrolled to during the postback. It's a page level property that is not visible anymore in the Properties Window. however drop into a code window and it there, under a different name:

Page.MaintainScrollPositionOnPostBack = True

For more info please follow this link:
How to implement the smart navigation features in ASP.NET 2.0

Saturday, August 11, 2007

Remove Remote Desktop IP Entries on Public Computer

I was teaching a class y'day when I saw trainee was search desparately to remove the remote desktop entry on his PC after he had successfully connected to his home PC. He was obviously worried that some other user may find the entry and start trying to establish a connection to his home PC. The moral of the story so far... don't use remote desktop from a public PC!!

Anyway the MSDN site proved as valuable as ever turning up this:
How to Remove Entries from the Remote Desktop Connection Computer Box

To remove entries from the Remote Desktop Connection Computer box in the Windows Remote Desktop Connection client, start Registry Editor, and then click the following registry key:
HKEY_CURRENT_USER\Software\Microsoft\Terminal Server Client\Default
Entries appear as MRUnumber, and are visible in the right pane. To delete an entry, right-click it, and then click Delete.

All have now vanished ... except for ONE; the default that you find as soon as you open Remote Desktop. After numerous reboots, logging off and on... the answer was easy... Go to my documents and remove the Default.rdp file. It's a hidden file so you won't see it unless you go to Tools->Folder Options-> View -> Show Hidden files and folders :)

Wednesday, August 1, 2007

AJAX Error: Error: Sys is undefined

AJAX Enabling an Existing ASP.NET Website!!

A common mistake new AJAX developers make is to just start adding AJAX controls to their existing ASP.NET 2.0 web project. However after adding say the time it will let you know that you need a scriptmanager control. That's easy, drag-drop , press F5 or right click, view in browser. Waaaahhh no AJAX, just a Javascript error in the bottom right of IE7, which when expanded states:
AJAX Error: Error: Sys is undefined
Well if we had started out with an AJAX-enabled Website and looked closely at the Web.config we would have noted one very important difference between the two:

<add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>

For more info:
How Do I: Add ASP.NET AJAX Features to an Existing Web Application?

Visual Studio 2008 Beta 2 - Part 1

Well it's starting to get exciting now that MS have dropped the 'Orcas' Code name and gone Beta 2 wit VS2008. Naturally I was on the download straight away, and just so as to save time I down loaded the Team Suite Virtual Hard disk. I loaded it up in Virtual Server 2005 R2 on my HP nc8430 Laptop with 2GB Ram and gave the VM 1GB. After linking the downloaded vhd to my base01.vhd I got the VM up and now it's time to play and see what's new.

Expect part 2 shortly :)

Saturday, July 28, 2007

Importing/process a CSV File in VB.NET

Some us developers love doing is data imports :P Even more so when it's CSV or worse still, fixed length fields!! :P Thank goodness VB.NET gives us the StreamReader which allows us to open a file with a single line of code, thanks to the constructor overload. This also allows us to trip through the file line by line by calling the read method and also returning False when it is EOF!! What's more we have the split function on the string to chop it up on any delimiter of our choice and push it into an array!! What more could we ask for! So here is the code snippet:
Dim sr As New System.IO.StreamReader("mycsv.csv")

Do While sr.Peek <> -1
Dim myflds() As String
Dim myline As String
myline = sr.ReadLine
myflds = myline.Split(",")
' now you have every field in a sep element array
' Push them into a db, whatever


Wednesday, July 25, 2007

Enabling ASP.NET 2.0 extensions on Windows 2003 Server

Whilst testing a clean installation of Win2K3 Server with IIS, SQL server 2005 and VS 2005 I tried to create a new ASP.NET project in IIS and got the following error:

Microsoft Visual Studio
Configuring web site 'http://localhost/WebSite' to ASP.NET 2.0 failed. You may need to manually configure this site for ASP.NET 2.0 in order for your site to run correctly.
OK Help

The problem is that ASP.NET extensions are prohibited from running on your computer by default. This is part of Microsoft's drive towards security by default (i.e out of the box). However it is easy to enable it by following these steps if you are working on Windows Server 2003
1. Open IIS Manager (open Run dialog from Start Menu and type 'inetmgr' in Start Edit Combo Box).
2. In the IIS manager window, expand the Local Computer node.
3. Click on Web Service Extensions node.
4. Allow "Active Server Pages" and "ASP .net v2.0.xxxxx".

Thursday, July 19, 2007

ALT Keycodes for Euro symbol and @ sign

I had a keyborad go crazy in a class today and needed a work around quickly :) For some strange reaon the @ symbol was not working inside the virtual machine!!! I had just had a request for the ALT code for the Euro symbol only a day before and found this link most helpful:

Just to summarise:
ALT + 0128 = €
ALT + 0064 = @

ALT + 0169 = ©

(NB. These have to use the left ALT key and the NUM KEY PAD. Can anyone tell me how to do this on a laptop without getting youyr fingers in a twist!!)

Wednesday, July 11, 2007

Get the current selected row in VB.NET DataGridView

Something that gets asked often in the forums is:
'How do I get a hold of the currently selected row in a datagridview?' so that I can pick a particular cell and manipulate it, use it for a calculation etc.

The trick is knowing that DataGridView1.CurrentCell will tell you the cell the user chose.
So if we ask for the Rowindex like this:

Then we can combine it with the Datagridviews rows collection to index just that row, like this:

We can take this further to drill into a column in that row by accessing the rows cells property like this:
DataGridView1.Rows(DataGridView1.CurrentCell.RowIndex).Cells().Value += 1

Saturday, July 7, 2007

Wireless Presenter Notebook Mouse 8000

OK so secretly I'm a bit of a hardware/gadegt junky, but this something I could really use (hint, hint for Christmas please, since I can't wait until my birthday) I really like the laser pointer, good for lectures/training. But the media Center edition controls make me feel like I'm on an i-Mac :) Take a virtual tour here.

Saturday, June 30, 2007

Triple/dual booting with Vista and Linux

I just got a 160GB SATA HDD for my Compaq nc8430 and of course I want to run all three OS's
Windows XP to get work done,
Vista to mess about and show off for now,
Linux to just play around.

Now some distros of Linux allow you to install the GRUB bootloader on the actual partition of the installation. This is great because:
1. Vista has already taken over the MBR and thus installin this after linux will render linux unbootable.
2. I know how to BCEdit better than I do GRUB :)

Luckily I found these guides which are idiot proof and so well documented.
The definitive dual-booting guide: Linux, Vista and XP step-by-step
But most especially this one:
How to dual-boot Vista with Linux (Linux is already installed)
Now although I put XP on first then Vista and then Fedora 7 I did put the GRUB on the Linux partition and so this is my set up :)

Tuesday, June 26, 2007

Inserting text into a Word Document from VB.NET

Another post to the 'Office Series', I used to do this everyday in a previous job!! Al we did was automate word, but using templates, which was much cooler. For now this just adds text into a word document.

Private WordApp As New Word.ApplicationClass()

Private Sub Button5_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button5.Click

' Choose a word document
If Me.OpenFileDialog2.ShowDialog() = DialogResult.OK Then
' Get the file name from the open file dialog
Dim fileName As Object = OpenFileDialog2.FileName
' Make word visible, so you can see what's happening
WordApp.Visible = True
' Open the document
Dim aDoc As Word.Document = WordApp.Documents.Open(fileName)
' Add the text and a line break
WordApp.Selection.TypeText("VB.NET Rocks")
End If
End Sub

Friday, June 22, 2007

Rotating and moving Graphics/images in VB.NET with Style

I saw a post recently that asked if you could rotate graphics in VB.NET. Now rotating a shape is one thing but an image provided more of a challenge. I knew that matrices are the way to go and not the mathematical calculations using pi, and cos and sin etc. But I also knew that matices cannot be applied directly to the image object. So I had to get my pic into a graphicspath. Well it appears that this is not too bad either. But as soon as I put all four points and decided to rotate, RotateAt gave me a not implemented error??!! So I put only three points and it worked!!! Well now my images is rotating, but flickering like mad. So I looked into double buffering, and finally I have a rotating/sliding image:

Imports System.Drawing.Drawing2D

Public Class Form1

Private Sub BackgroundWorker1_DoWork(ByVal sender As System.Object, ByVal e As System.ComponentModel.DoWorkEventArgs) Handles BackgroundWorker1.DoWork

Dim RotateAngle = 1
Dim offset As Integer = -10
Dim tickcnt As Long = Now.Ticks

Dim BackBuffer As New Bitmap(Me.ClientSize.Width, Me.ClientSize.Height)
Dim DrawingArea As Graphics = Graphics.FromImage(BackBuffer)
Dim Viewable As Graphics = Me.CreateGraphics()
Dim TopRight As New PointF(800, 50)
Dim i As System.Drawing.Image = My.Resources.MyPic
Dim myPath As New GraphicsPath
Dim OrigPoints() As PointF = {TopRight, New Point(TopRight.X - i.Width, TopRight.Y), New Point(TopRight.X, TopRight.Y + i.Height)}
Dim translateMatrix As New Matrix()

Do While Not Me.BackgroundWorker1.CancellationPending

If Now.Ticks - tickcnt > 500000 Then
RotateAngle += 10
offset -= 5

' Do the transforamtion on the Image
translateMatrix.RotateAt(RotateAngle, New Point((TopRight.X - i.Width / 2) + offset, (TopRight.Y + i.Height / 2)))
translateMatrix.Translate(offset, 0)

'Apply it to the path
'DrawingArea.DrawString(myPath.PathPoints(0).X, New Font("Arial", 10, FontStyle.Regular), Brushes.Aqua, TopRight.X, TopRight.Y)

' Draw the image with the new points
DrawingArea.DrawImage(i, myPath.PathPoints)

Viewable.DrawImageUnscaled(BackBuffer, 0, 0)

tickcnt = Now.Ticks
End If

End Sub

Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
End Sub

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub

Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint

End Sub
End Class

Tuesday, June 19, 2007

Accessing Outlook Address Book from VB.NET

Had someone ask me this a while back and lost the link so I decided to blog it this time. As always dont' forget to add a COM reference to your project for the Microsoft.Outlook x.0 Object library in order to create the necessary objects.

Dim oOutlook As New Outlook.Application
Dim oNS As Outlook.NameSpace
Dim oContacts As Outlook.MAPIFolder
Dim oItems As Outlook.Items
oNS = oOutlook.GetNamespace("mapi")
oContacts = oNS.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderContacts)
' set to the contact folder
oItems = oContacts.Items.Restrict("[MessageClass] = 'IPM.Contact'")
' filter to select only contact items
oItems.Sort("[EMail1Address]", False) ' sort by email address

For Each oct As Outlook.ContactItem In oItems
MessageBox.Show(oct.CompanyName & "-" & oct.BusinessTelephoneNumber)

Sunday, June 17, 2007

Loading Assemblies into an AppDomain

'Creating the AppDomain
Dim d as AppDomain = AppDomain.CreateDomain("NewDomain")

'Load the assembly using path

'Load the assembly from a referenced library

'Unload it

Reading/writing Excel files in VB.NET

Now there seem to be a few examples of how to do this in C# but few comprehensive ones in VB.NET. So here's how to let the user choose an excel file and then write to cell A1 and read from cell A2. Don't forget to add a reference to the Excel COM library.

Also add Imports Microsoft.Office.Interop to the first line of your class/form

Dim xcFileInfo As IO.FileInfo
Dim xcFileDialog As New OpenFileDialog()
xcFileDialog.Filter = "Excel Spreadsheet Files!*.xls"
xcFileDialog.Title = "Select estimate in excel spreadsheet file!"

If xcFileDialog.ShowDialog = DialogResult.OK Then
xcFileInfo = New IO.FileInfo(xcFileDialog.FileName)
End If

Dim myExcel As Excel.Application ' Interface to Excel
Dim myWorkBookCollection As Excel.Workbooks ' Workbook-collection (note the 's' at the end)
Dim myWorkBook As Excel.Workbook ' Single Workbook (spreadsheet-collection)
Dim myWorkSheet As Excel.Worksheet ' Single spreadsheet

' Initialize the interface to Excel.exe
myExcel = New Excel.Application

If myExcel Is Nothing Then
MessageBox.Show("Could not load Excel.exe")
Exit Sub
End If

' initialise access to Excel's workbook collection
myWorkBookCollection = myExcel.Workbooks

'open spreadsheet from disk
myWorkBook = myWorkBookCollection.Open(xcFileInfo.FullName, , False)

'get 1st sheet from workbook
myWorkSheet = myWorkBook.Sheets.Item(1)

'alter contents of 1st cell
Dim myCell As Object = myWorkSheet.Range("A1", _ System.Reflection.Missing.Value)
myCell.Value2 = "I did it again!!!"

'display the spreadsheet
'myExcel.Visible = True
'Read Cell A2

Dim myCell2 As Object = myWorkSheet.Range("A2", _ System.Reflection.Missing.Value)

Me.Text = myCell.Value2

'save and get out

Thursday, June 14, 2007

Can't upgrade/install SQL 2005 Express Workstation tools

If you are like me, you installed VS2005 and forgot to tell it not to install SQL Express, because you just knew that later you were going to install SQL Server 2005 Developer Edition. Now I managed to install SP2 for Express and all was OK until the day I decided to install SQL 2005 Dev Edition. I get a little error saying version warning but ignored it, only to find out that it will install all the goddies except the most important one, SQL Management Studio. Ahhhhh, so the whole install goes through and I now have tow SQL Servers but no management tools!!! Now I know you are saying, ' why don't you use the osql?' Yeah it's great, but somethings are just easier with the GUI, I want THAT GUI!!! So I read the warning message again, and googled to find Upgrade a SQL Server Express Report Server to Other SQL Server Editions Well now it's easy. I didn't want to upgrade the whole of SQL Express, just the workstation components. So I launched the setup of the just the tools, not the server with the switch mentioned.


Now I can tick on the workstation components .... and all's well :)

Wednesday, June 13, 2007

MSDN Forums (Part II)

Well something just worth shouting about :) two weeks in and 36 answers !! Now I'm in the top 100.
9th in VB General
8th in VB IDE
10th in VB Express

Wednesday, June 6, 2007

MSDN Forums (Part I)

OK time for a little pat on my own back. I started looking in on the MSDN Forums, trying to lend a hand to those stuck on anything VB.NET related. I'm mainly looking at VB.NET Express and the 3 VB.NET ones:IDE, Language and General. Well after a week of posting replies. I've got in to the top ten of the VB.NET:IDE, yeah. So 37 posts in a week is not too bad. I think the forum is a great place to learn and get help, so many great people pumping ideas in so please take a look.

Saturday, June 2, 2007

Setting NTFS Directory/Drive permissions in VB.NET 2005

It seems setting File Permissions in 2005 is easy, but there didn't seem to be much regarding directory or drive ACL's. So a little digging and adapting goes a long way .....

Dim folder_info As New DirectoryInfo("C:\")
' Read the current ACL
Dim foldersecurity As DirectorySecurity = folder_info.GetAccessControl _

' Make up my new ACE
Dim MyRule As New System.Security.AccessControl.FileSystemAccessRule _
("DOMAIN\USER", FileSystemRights.FullControl, AccessControlType.Allow)

' Add it to the old ACL
' Apply it

Friday, June 1, 2007

Marking madatory textboxes/fields with style

Now everyone in VS2003/2005 who likes graphics has done some code in the onPaint event to draw nice little things, but have you ever tried drawing on a textbox, or any other control for that matter. Wemay also be tired of just filling madatory fields with a plain backcolor fill also. So what I set out to do was draw a nice little glyph in the corner to signify that a filed was mandatory

First off we must subclass the good old textbox, but hopefully you aer doing this already in your component lib. Next it's a matter of hooking up to the windows message and drawing accordingly.

Public Class Component1
Inherits TextBox
Private Const WM_PAINT As Integer = &HF

Private bMandatory

Public Property Mandatory() As Boolean
Return bMandatory
End Get
Set(ByVal value As Boolean)
bMandatory = value
End Set
End Property

Protected Overrides Sub WndProc(ByRef m As Message)
If m.Msg = WM_PAINT And bMandatory Then
Dim g As Graphics = Me.CreateGraphics
Dim pts As PointF() = {New PointF(0, 0), New PointF(5, 0), _
New PointF(0, 5)}
g.FillPolygon(Brushes.Red, pts)
End If
Catch ex As Exception
' Call error handler
End Try

End Sub

End Class
You should end up with this ...

Wednesday, May 30, 2007

Adding a DateTimeStamp to a file

' Get the current Date Time and remove illegal chars
Dim strDTStamp As String = Format(Date.Now, "yyyyMMddHHmmss")

' This is the file we want to rename
Dim of As String = "C:\Myfile.txt"

' Insert DTStamp into the old name
Dim nf As String = of.Replace(".", strDTStamp & ".")

' Moving the file is like renaming it
System.IO.File.Move(of, nf)

Resizing images/bitmaps the Visual Studio 2005 Way!

I've see so many ways to do this but this is so elegant it rocks. Here's how to resize an image in VB.NET 2005

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim MyImage As New Bitmap("D:\My Documents\My Pictures\untitled.bmp")
Dim MyThumbNail As Image
MyThumbNail = MyImage.GetThumbnailImage(MyImage.Width/2, MyImage.Hieght/2, AddressOf ThumbNailAbort, Nothing)
MyThumbNail.Save("D:\My Documents\My Pictures\Thumb.bmp")
End Sub

Private Function ThumbNailAbort() As Boolean
'Do Nothing Here
End Function

The delegate ThumbNailAbort is necessary, even if it is not yet implemented yet in .NET

Tuesday, May 29, 2007

Hiding Tabs ain't the same anymore

If you are like me and remember VB6 all too well this code would appear to be the logical way to hide a tab:

TabControl1.TabPages(1).Visible = False

Now althought this compiles it does nothing

What's stranger is that:
TabControl1.TabPages(1).Enabled = False
does work as expected!!

So the only way is to remove it. But don't worry it does not unload it from memory so we can always add it back into the tabpages collection to get it back:

TabControl1.TabPages.Remove (TabPage1) or RemoveAt(index)
to get it back. What's more make sure you use the object as the parameter and not a string :)

Hiding a file in .NET 2005 and other tricks

Really easy:
File.SetAttributes("" & strFileName & "", FileAttributes.ReadOnly + FileAttributes.Hidden + FileAttributes.System)

Make sure you import System.IO

Sunday, May 20, 2007

10 steps to a clean Install of Windows XP on HP nc8430 Laptop

If you are anything like me, when you get a new laptop all the extra stuff loaded on by the vendor will just bug you like crazy until you end up doing the inevitable.... a clean install. Well this was easier said than done in my case. Vista loaded like a dream, no time atall to install, but once loaded with VS2005 and SQL server and all my dev stuff, well my machine just could not take it. I guess I really need that 2GB of ram upgrade and a larger HDD, but that's another story.

So I read and read for days about how to slipstream the SATA drivers into the XP install CD, otherwise you just get a harddisk cannot be found during the standard insatll. This was before I bought an external floppy, extracted the drivers from the HP site onto it and then did the famous F6 during the installlation to specify other drivers. I though hey presto I'm there, only to find that the second time the installation requests them the drive is not found. It turns out the Windows only accepts a handfull of external floppies, and guess what, mine was NOT on the list :(

So after 4 failed CD burns I finally get the installation in. Whoooo.... but on reboot, I get a flash of a BSOD and the system just keeps rebooting. SO I contact HP, cos by now I'm going mad. They tell me to install with native SATA disabled and then put the drivers on and then switch it back on. So here's how to do it:-

1. Set Native SATA to DISABLED then install the OS in the normal fashion.

2. Download the latest “Intel Matrix Storage Manager” driver.

After downloading the “Intel Matrix Storage Manager” create one folder named Sata and copy the iata61_enu.exe which you just downloaded from above mentioned link.

3. Use following command to extract the driver files:
c:\sata\ iata61_enu.exe -a -a -pc:\sata
When run, the installation process begins; simply click through the dialogs as prompted. This will not install the driver, it will only extract the driver files to . After the extraction is completed, the driver files can be found in .

4. Install the Intel chipset driver for example "sp32781. Intel Chipset Inst Utly for ICH7 . REV_ A.txt"

5. Update the ICH-7 controller that was just added from the chipset driver

6. Here are the steps for walking through the wizard.

6a. No not this time
6b. Install form a list or specific location
6c. Don't Search, I will choose the driver to install
6d. Have disk
6e. Browse to C:\SATA\Driver
6f. Choose the 82801GMB SATA AHCI Controller
6g. Say yes, you do want to install although it is not signed

7. Reboot into the BIOS settings using the F10 function key as the system is coming up.

8. Change the BIOS settings back to Native SATA ENABLED and REBOOT once again.

9. After reboot, the additional SATA components will be updated and allow you to enter Windows normally and you will be prompted to reboot again:.

10. Finally you will have the driver completely installed

Wednesday, May 16, 2007

Office shortcut keys

I've been doing a bit of office spreadsheet reporting these last few days and it was driving me bonkers to prepare the format the way I wanted it. What I had to do was basically highlight certain rows and delete them over and over. Now on a laptop infront of TV you could really do with shortcut keys and not the the old mouse. So I did a quick search and came up with:

Highlight Row => "Shift" + Spacebar
Highlight Column => "Ctrl" + Spacebar

To insert a row, hit "Ctrl + '+'"
To delete a row, hit "Ctrl + '-'"

Some others whilst I'm at it:
Ctrl+9 Hide Cell
Shift+Ctrl+9 Unhide The cell
Ctrl+0 Hide the Column
Shift+Ctrl+0 Unhide The Column

For the complete list for keyboard junkies visit:

Monday, May 7, 2007

HP Pavillion t3000 desktop PC automatically restarts after immediately shutdown

Had a strange problem the other day, the PC was shutting down and then rebooting straight away. So the poor PC owner was waiting until the exact momment between safe shutdown and restart to power off the PC. After a little digging, that did not turn up much from the event log etc, I decided to turn off the windows feature that automatically reboots the machine after a critical error occurs. This can be found under control panel, system, Advanced tab, Startup and recovery options. With this in place, a shutdown revealed a STOP error on a BSOD. "STOP 0x000000D1 IRQL_NOT_LESS_OR_EQUAL Kbdclass.sys" Error Message When You Try to Shut Down the Computer So now it was quite obvious that the mouse driver need upgrading because it happened to be a logitech mouse. Problem solved ;)

Thursday, April 26, 2007

Can't open office 2003 .mdi files using Office 2007

I recently saved a whole load of tutorials in MS Office's .mdi format using 2003 so as to save some trees :) I was quite surprised when I loaded these files onto my machine with office 2007 because they could not be opened. Now Office 2007's electronic format is in .xps so I knew I had a problem. Quick search on google turns up an MS KB article to solve the problem:-

1. Click Start, click Run, type appwiz.cpl, and then click OK.
2. In the Currently installed programs list, click the 2007 Office version that you have installed.
3. Click Change.
4. Click Add or Remove features, and then click Continue.
5. Expand Office Tools.
6. Click Microsoft Office Document Imaging, and then click Run all from My Computer.
7. Click Continue.

Ref: An .mdi file does not open in the Microsoft Office Document Imaging program that is included in the 2007 Office programs

Tuesday, April 24, 2007

Fixed Length String in Visual Basic.NET

Yes this can be done quite simply:

Structure Student
Public ID As Integer
Public DatofBirth As Date
<VBFixedString(15)>Public FirstName As String
<VBFixedString(15)>Public Surname As String
End Structure

For more details check out this MSDN article.

Wednesday, April 18, 2007

Remote Desktop Troubleshooting - Don't forget the obvious!!

Just had a another problem reported... For some reason a remote desktop had suddenly stopped allowing incoming connections at one of my clients. After checking around I found that the firewall had disallowed RDP on the exceptions tab. Now we all know that allowing RDP when you right click My Computer and go properties... remote... will automatically allow an excpetion in the firewall by default. So guess what, initially I did not think of checking that. It was only after I started pinging the machines that it dawned on me to check the firewall (and also thanks to this brillaint guide on the MS site!)

I can only guess, after speaking to the admin on site that after he applied a recent update to the Remote Desktop client, it got turned off but never back on. Now he did then mention that the update had hung and he canceled the update!!! Make sense?... perhaps :)

Could not load file or assembly 'Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its ...

Could not load file or assembly 'Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.

I just had a call from a client asking how we can solve this error while he was deploying his Intranet from his local machine to the production server. After a lot of searching he was linked to the MS site and asked to request a hotfix (FIX: You may receive an InvalidCastException error in an ASP.NET-connected Web application)

loadTOCNode(1, 'symptoms');
You may receive an InvalidCastException error in a Microsoft ASP.NET-connected Web application when the following conditions are true:
• The Web application uses a master page, a user control, or pages that reference each other.
• The master page, the user control, or the pages are batch compiled into a single assembly.
• One of the batched dependencies is changed and causes a recompilation.
• A dynamic call to load a reference is made, such as a call to the LoadControl method. In this case, you may receive an error message that resembles the following:
Unable to cast object of type 'ASP.type' to type 'ASP.type'.Note In this error message, type is a placeholder for one of the batch compiled types. You may also receive an error message that resembles the following:
Could not load file or assembly 'App_Web_xxxxxxxx, Version=, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.

Now he had been using master pages and webcontrols etc.. so the fix was tempting.. However as a precaution he called me and I looked deeper....
Enter ..... AJAX

Luckily I remembered he had just added AJAX to the site only a few days ago and so I dug some more. Finally tried out the site on a test server and reproduced the error but then I confirmed that installing the Ajax 2.0 Extensions would fix it..... and it DID!!

Thursday, April 12, 2007

MODL Certification Bootcamp

I've just finished attending my first ever Microsoft Offical Distance Learning Boot camp and I'm telling you it was excellent!! I must admit I was a bit apprehensive having to deliver a 30 minute presentation to what I was imagining to be a brick wall!!! Boy was I wrong I can honestly say it is certainly not a revamped E-Learning. First off, Microsofts Live meeting was an excellent tool for the job and I think without it, it just would not work. Engaging the others in the classroom with the annotation tools is just great, especially since I like to talk with my hands (go figure how you convey that over the web when they cannot see you!! ) Anyway I must say a huge THANK YOU to David Clarke at Toolwire who facilitated our session. You really have done a fantastic job of innovating the learning experience!! Also Ron and Henk were great MCT’s to deliver too, thanks for making the classroom so much fun. We really had fun with that highlighter tool I think!!!

Well now that the G(ather) part is ready, I can’t wait to see the EAR part come into place. The E-Learning is great, especially after having been prepped by the Virtual classroom. The online ‘Day in the life’ environment where you get to play on the ‘toolwire’ campus is also amazing. You get to use a real server and configure it with what you have learnt with a real life scenario all over the internet. Toolwire have put in over 1000 servers to support the hand’s on part!!!

Well I’ll certainly post more as this progresses, especially once the official result is out :) In the meantime check out the Microsoft Offical Distance Learning site for more details!!!

And these are the courses currently available.

Friday, March 23, 2007

The waiting is over

Hey it's offical, I'm NOOOOOOT going to Tech-Ed 2007 in the US THIS year! So it's time to start preparing :) Anyway, there were over 350 applications when I put mine in on Sunday night March 4th so thats a lot to compete with, considering so few are chosen from outside the US. Some great MCT's going to help out so I'm sure it's going to be a blast.

Monday, March 19, 2007

Tech Ed 2007 US Waiting ....

I'm waiting like so many other MCT's in the hope of being selected as TLG or ambsaasdor. But as the days pass I'm already starting to plan for next year! :) and for Tech-Ed 2007 Developers in Barcelona Tech-Ed 2007 Developers in Barcelona. In the meantime work continues on the Malta User group Visual Studio Developers....

Sunday, February 18, 2007

DevNET Malta

I've secured premises where we can now hold our monthy 'geek meetings', although I kindly asked those interesting in attending to come up with something a little cooler:) The place STC Training is nice and central, well equiped and spacious and has it's own canteen!! So coffee and goodies will be in ample supply!! The center has great labs which will be configured for hands-on after the presentations so that attendees can get their hands dirty!! Some of the first few topics will be based on the following areas:
3D Graphics
Asynchronous programming
"Click-once" deployment

Sessions are expected to last approximately 1-1.5 hrs and take place once a month initially, at 6:00pm on Tuesdays. So please block your diaries!!! More News later.