Friday, February 22, 2008

Windows Vista SP1 for x86 and x64 is here!



Yes Microsoft have released SP1 for Vista. I downloaded it today on DVD for x86 and x64 thru the MSDN site. There is a great 53 page document what has changed with this release, hopefully I'll have time to read it and blog it!! If I don't the link is here. There is also some info on the TechNet site here. Once I installed it I just had to take these two screen shots.


I dig the the caption in this one:


Monday, February 18, 2008

Project 'SilverlightProject1' could not be opened because the Microsoft Visual Basic 2008 compiler could not be created. Unable to find required file

I've been working fine with Silverlight under my VS 2005 installation but recently I said I'd start doing that work in VS2008. So I installed the Silverlight tools for VS2008 and found a nice new project template for Silverlight projects and class libraries. I clicked it and got a nice Error:

Project 'SilverlightProject2' could not be opened because the Microsoft Visual Basic 2008 compiler could not be created. Unable to find required file 'mscorlib.dll'.

So I hunted around the web and ended up on ScottGu's blog, surprise:) Some said ditch VB.NET and use C#. Sure enough the C# project worked fine, grrrr. So I uninstalled Silverlight 1.0 and tried the Silverlight 1.1 alpha September refresh. Guess what all is OK. Works a charm in VB.NET.

Accessing resources in a non-typed way in VB.NET

OK so the my namespace is really cool, but sometimes we just want more!! to get at a string in the resources of an app is easy. Go to the project tab, add astring resource with the name CompanyName and then type the value in the field nextdoor. Access the value in code like this

label1.text = My.resources.CompanyName

Now intellisense haspicked up the strongly type property and helps you. The same works for images, add an image to the resource file, browse for it and name it Image1. The following code also works:

Picturebox1.Image = My.resources.Image1

Note no need for the extension and also the intellisense pops up again. You just have to love this!!

So now you want to load a random file from the resources, like a random picture..... hmm this strong typing is getting in the way now grrrr.

Do not fret use the resourcemanager, this lets you get to any resource in the current assembly using a string paramater with its name. YES

So imgine you have 10 pics, called 0.jpg, 1.jpg, 2.jpg etc and you want to load them randomly

so the code now looks like this

Dim intNumber as integer = System.Convert.ToInteger(Math.rnd() * 9 )
Picturebox.Image = CType(My.resources.ResourceManager.GetObject(intNumber), Image)


You can also call the GetString method to pull strnig resources in an untyped fashion!!

Friday, February 15, 2008

Web Parts common Error when getting started

A common error many ASP.NET 2.0 beginner developers make is that when they decide to get into WebParts they drag a WebPartManager on the screen and a WebPartZone and then bung in a control. To their dismay, when they press F5 to run the program they get a nasty error like this:

Error:Server Error in '/WebSite1' Application.--------------------------------------------------------------------------------
An error has occurred while establishing a connection to the server. When connecting to SQL Server 2005, this failure may be caused by the fact that under the default settings SQL Server does not allow remote connections. (provider: SQL Network Interfaces, error: 26 - Error Locating Server/Instance Specified) Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. SQLExpress database file auto-creation error:

Now this error may appear completely unrelated and confusing but it makes sense when you know why ASP is complaining. Basically the WebPartManager is trying to contact the profile store to save your persoanlisation settings, which happen to default to SQLServer by default. Now your app is clean and you have not specified anywhere that you wanted to SQL as your profile storeor perhaps you don't have SQL even installed. So to get around this just switch off the webpartmanager personalisation by setting its personalisation attribute to false:

<asp:webpartmanager id="webpartManagerSampleSite" runat="server" enabled="false"></asp:webpartmanager>

Friday, February 8, 2008

Windows 2008 Server RTM

It's here, yes 18 days before the 2008 Global Launch Wave, three versions have been RTM'ed and are now available for download to MSDN subscribers:
  • Standard Edition,
  • Enterprise Edition and
  • Datacenter Edition.
All are available in x86 or x64 versions :)

The x86 version is a 1794 MB download. As you can see I couldn't wait to get it installed and try it out!!
BTW, the virtual machine had 800MB of RAM and installed in about 15-20 minson a Core2Duo 2.4Ghz HP laptop. The Hard Disk now occupies 5.7GB of space :)

Saturday, February 2, 2008

ASP.NET 2.0 Dynamic master page switching

I've been delving into master pages this week and found some really neat features that alot of people often ask for. This I think is one of them. In the next three steps I show you how to allow the user to switch masterpages. Basically the idea hinges on the fact that the masterpagefile property of a page can be switched at runtime, but it has to be done in the preinit event of the form with the content. The users selection can be stored in any session management storage. So here are the steps:


  • Create two or more master pages with the same ContentPlaceHolder controls and public properties. These could be straight copies or better still two child masters based on the same masterfile
  • Optionally, provide a way for users to switch between master pages.

Session("masterpage") = "Master2.master"

Response.Redirect(Request.Url.ToString)

Assign the master page in the content page’s Page_PreInit method.

Sub Page_PreInit(ByVal sender As Object, ByVal e _ As EventArgs)

If Not (Session("masterpage") Is Nothing) Then

MasterPageFile = CType(Session"masterpage") ,String)

End If

End Sub

Tuesday, January 1, 2008

1st European Silverlight Challenge


Thanks to my good friend Daniel Joskovski in Macedonia I am proud to say that Malta will be hosting the 1st European Silverlight Challenge on a country level. The winners of this will go through to compete on a international level against other European finalists. The aim is to develop a Silverlight Web Component that can be GPL'ed for use by other Usegroups. To participate please direct your browser to our site at: http://malta.silverlightchallenge.com. Here you will find all the info you need to enter the competition, what you need to do, the rules, and of course the prizes (or SWAG as they say in the UK)!!! The deadline is the end of this month for submissions so hurry. I'm telling you the prizes are cool, so hurry!! As a bonus, the devNET user group will be holding a Silverlight presentation to help you get started. Details can be found here: http://www.devnetmalta.com/dnn.