Thursday, July 05, 2007

Personal review of Visual Studio Orcas beta 1

Hi all,

I know it's been a while, usual stuff really, swamped in a project up to my neck!
Blogging then becomes less of a priority ;)

However let me tell you a few things about the new Microsoft Visual Studio "Orcas" beta 1 release, which I am currently testing on my huge dual core AMD 64 bit, 4 Gb RAM, 500 Gb hard drive, Vista 64 business monster of a development machine.

I have to say, this release looks amazing and is packed with functionality that I have really been looking forward to.

However first impression is : very slow compared to VS 2005 (even on the PC described above). Maybe it's due to all this fancy new intellisense that ships with it, but big pages/controls take longer to be loaded/compiled. Don't even try the design view for complex pages, it's a nightmare... I've just disabled it.

Still, it's very usable and my general view on this new product is very positive indeed.

The good bits:
  • Much better intellisense
  • Great client side script step-by-step debugging!!! (F10 works on client side scripts!!!)
  • LINQ (fantastic)
  • Support for WPF and SilverLight (still have to be convinced by SilverLight I have to say...)
The bad bits:
  • Quite a bit slower than VS 2005 although usable
  • Had a few nasty crashes when "alt-tabbing" between a resource file (as in localization resource file) and a text editor called EditPadLight that I really like.
  • Other miscellaneous crashes, but nothing too bad for a beta release ;)
  • The "Copy website" function is still very bad and could have been improved...
So basically, my initial mark for Visual Studio Orcas beta 1 is: 85%

Will definitely make the move when it's released. Thanks for reading!

Cheers people and take it easy.

PS: You can find the Visual Studio "Orcas" files here:

If you need tips to download the huge image files from the Microsoft website, read Jon Galloway's blog otherwise you can use the MSDN Subscriber downloader as explained on the link above:

Monday, May 14, 2007

How to get the ASP.NET Commerce Starter Kit 2.0 to run in medium trust !

Hi guys,

I am sure many of you will loooove this article.


You can follow the instructions below, alternatively you can download the C# code from my SkyDrive:

I have been now fighting for a while to get the wonderful ASP.NET Commerce Starter
Kit 2.0 to work on my ISP Shared hosting server.

At first I thought it was a lost battle and started coding the CSK without SubSonic, Entreprise Library or any of this fancy stuff that requires full trust to run properly.

But after battling harder, I noticed a few things that changed my life yesterday and let me share my findings with you all!

Here is how I got there :

1. I added this line in the CSK web.config so it would simulate my hosting service environment on my dev machine :

<trust level="Medium" />

I also prevented SubSonic from using the Entreprise Library data access and to use the more supported SqlDataProvider (not sure this made a difference but I would like to mention it) :

<SubSonicService defaultProvider="ELib2DataProvider">
<!--<add name="ELib2DataProvider" type="SubSonic.ELib2DataProvider, SubSonic" connectionStringName="CommerceTemplate"/>-->
<add name="ELib2DataProvider" type="SubSonic.SqlDataProvider, SubSonic" connectionStringName="CommerceTemplate" />

2. I updated the ATLAS stuff with the latest from Microsoft (optional):

Notes :

  • With that step more changes to the web.config are required (cf the web.config of the ajax web extensions).
  • Also I moved the ScriptManagers to the master pages (admin and site) and removed them from other pages, that way you always have ajax enabled pages :)
  • There is also an attribute that you need to remove from the ScriptManager or it won't compile.
  • One last thing you also have to replace the "Mode" attribute of all your UpdatePanels and change it to "UpdateMode".
3. In the App_Code\Configuration\SiteConfig.cs change the lines that say:
config.GetSection... to ConfigurationManager.GetSection
And rem out the line that says :

Dim config As System.Configuration.Configuration = WebConfigurationManager.OpenWebConfiguration(HttpContext.Current.Request.ApplicationPath)

This will try to access your web.config file and save it, which is NOT allowed in partial trust.
The only pages that use this to write to the file are the Payment, Shipping and Tax configuration pages in the admin. I have simply disabled the "" (i.e. rem'd it out) in those pages and you just need to go and configure those values manually in the web.config before you publish the code.

4. Next thing is to get rid of the eWorld.UI assembly all together cause it needs full trust to run and to replace the controls used in the CSK by nice new shiny AjaxControlToolkit controls (NumericBox to TextBox and Calendar are the only ones that I found in the project). Best to delete the eWorld.UI.dll from the bin folder and compile to see where we have to make the changes :o)

In order to use the AjaxControlToolkit you must put the AjaxControlToolKit dll in your bin folder and register it in the page :

<%@ Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %>

Then you can replace everywhere it says "ew:NumericBox" by "asp:TextBox" and get rid of the :

<%@ Register Assembly="eWorld.UI" Namespace="eWorld.UI" TagPrefix="ew" %>

Finally for the calendar, replace :

<ew:calendarpopup id="txtExpirationDate" runat="server"></ew:calendarpopup>


<asp:TextBox ID="txtExpirationDate" runat="server"></asp:TextBox>
<ajaxToolkit:CalendarExtender ID="CalendarExtender1" runat="server" TargetControlID="txtExpirationDate" Format="dd/MM/yyyy" />

Another thing, once you have done that some of your code behind files will stop working and you will have to replace the old "PostedDate" or "SelectedDate" of the old calendar controls by the "Text" property of your textbox.

Also everytime you need to set a datetime datafield just do DateTime.Parse(textbox.Text) instead of the old eWorldUIOldTextBox.SelectedDate.

There will also be occurrences of this sort of thing which will not pass the compilation:

calEnd.SelectedDate = DateTime.Today

Just replace it with:

calEnd.Text = String.Format("{0:dd/MM/yyyy}", DateTime.Today)

Or this sort of thing :


Replace it with :


There might be more small code changes that I forgot to document here but I will let you find out by yourself, you've got the general idea!

Once the project compiles locally with those changes and in medium trust (cf step 1) then you can publish it (Build > Publish Website) and compile it to a location on your hard drive. Copy the files to your ISP with the correct DB connection strings and that's it! (I agree it's actually quite a lot!)

If you need the code, drop me a line with your email address and I will send it to you.

I have tried to look at contributing in CodePlex for the CSK but the lack of documentation on how to do that made me loose motivation...

On the other hand, the changes that I have made so far may have other impacts on other functions of the CSK so following my advice is at your own risk, you are responsible for any change you make to the code :o)

From what I have seen so far though, everything works like a charm on a shared hosting server!!!

Good luck and let me know your feedback.


"The SqlParameterCollection only accepts non-null SqlParameter type objects, not QueryParameter objects" ERROR

I received quite a few emails about this as it is a problem when using the CSK code and the solution is here:

You need to edit the OrderController.vb (or .cs) to include this function:

Public Shared Function GetDBCommand(ByVal objSubCom As SubSonic.QueryCommand) As DbCommand

Dim objDbCom As DbCommand
Dim objSqlCon As New SqlConnection(ConfigurationManager.ConnectionStrings("LocalSqlServer").ToString)

objDbCom = objSqlCon.CreateCommand()
objDbCom.CommandText = objSubCom.CommandSql
objDbCom.CommandType = objSubCom.CommandType

Dim par As QueryParameter
Dim objSqlParam As SqlParameter

For Each par In objSubCom.Parameters

objSqlParam = New SqlParameter

objSqlParam.DbType = par.DataType
objSqlParam.ParameterName = par.ParameterName
objSqlParam.Value = par.ParameterValue


Return objDbCom

End Function

Then replace all the lines that say:


With this line calling the new function bypassing the subsonic call:


The ToDbCommand is the one causing the error and it's a Subsonic function. It is only throwing the error when using the SqlProvider to connect to the DB (from the SubSonic dll). So the new GetDBCommand that I wrote is a workaround that bypasses that function...

Add columns programmatically to a GridView and style the rows

A friend of mine asked me how to programmatically add columns to a GridView and I found this great article which I hope will help some of you too :

He also asked me how to style the Grids the best possible way and to modify the style of some control in it, maybe just one cell.

As far as the general style is concerned I advise you to use a .skin file in the "Themes" folder of your ASP.NET 2.0 app. In this file the following declaration will map the GridView items to CSS classes :

<asp:GridView SkinID="" runat="server" CellPadding="4" GridLines="Both" CssClass="GridView" Width="100%" BorderColor="#ECECEC" BorderStyle="Solid">
<HeaderStyle CssClass="GridHeader" />
<FooterStyle CssClass="GridFooter" />
<SelectedRowStyle CssClass="GridSelectedRow" />
<AlternatingRowStyle CssClass="GridAlternatingRow" />
<EditRowStyle CssClass="GridEditRow" />
<RowStyle CssClass="GridRow" />
<PagerStyle CssClass="GridPager" />
<EmptyDataRowStyle CssClass="GridEmptyRow" />

In a css file, you can then create the relevant classes like GridHeader, etc.

If you need to modify a row or some element of it when the Grid is being "written" you should do it in the RowDataBound event as follows:

Protected Sub myGridView_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles myGridView.RowDataBound()
If e.Row.RowType = DataControlRowType.DataRow Then
Dim objButton As Button
objButton = CType(e.Row.FindControl("cmdButtonInTheRow"), Button)
If IsDBNull(e.Row.DataItem("MyDataFieldValue")) Then
objButton.Enabled = False
ElseIf e.Row.DataItem("MyDataFieldValue") = "SOME_VALUE" Then
objButton.BackColor = System.Drawing.Color.FromName("White")
objButton.BackColor = System.Drawing.Color.FromName("Green")
e.Row.BackColor = System.Drawing.Color.FromName("Red")
e.Row.Cells(3).BackColor = System.Drawing.Color.FromName("Yellow")
e.Row.Cells(4).ForeColor = System.Drawing.Color.FromName("Pink")
End If
End If
End Sub

Hope this helps!


Tuesday, April 10, 2007

The coolest shortcut of them all !...

Hi people,

In the shortcut series, I have found the coolest of them all!
The new ALT+TAB in Vista :

Try the "Windows Key" + TAB and tell me what you think...

If you want more here it is

I am really starting to love Vista, the only thing I don't like about it is that I'm going to have to buy 2 more Gb of RAM...

Oh well... progress hey?

Thanks to Microsoft for a cool OS!

Wednesday, March 28, 2007

NetSpell checker works in medium trust environment using AllowPartiallyTrustedCallersAttribute

Hi all,

just a quickie, I have been using this fantastic open source free spell checker and I am very happy with it as it is completely integrated to the FreeTextBox.

It is called NetSpell and in order to download it you must go to this site :

The problem is when you try to make netspell work in a shared hosting environment that will be more secure than your dev webserver and will more than likely run in medium trust.

The only problem is that NetSpell does not by default allow the assembly to run in partial trust and therefore the only way to get it to work is to add :

[assembly: AllowPartiallyTrustedCallersAttribute()]

line to the AssemblyInfo.cs file of the NetSpell.SpellChecker project


1. I downloaded the code locally to my C: drive,
The full source is available here using the mighty SVN source code manager :

2. Went to the ..\NetSpell\trunk\NetSpell\src\NetSpell.SpellChecker folder,
3. Edited the AssemblyInfo.cs file to include [assembly: AllowPartiallyTrustedCallersAttribute()]
4. Added a reference at the top of the file to using System.Security;
(required for the AllowPartiallyTrustedCallersAttribute element to work)
5. Recompiled the project
6. Copied the new NetSpell.SpellChecker.dll to my web project and...
7. BINGO! everything worked like a charm on my medium trust environment!!!

Hope those who struggled with this will manage to find my post and solve their problem!


Friday, March 09, 2007

New tool!

I just had a look at Wengo Visio and it seems to be amazing...
I will try it a bit more and let you know how it works but it looks amazing!

It's like Skype but Flash based and does not require any client install!!!

Let's try it:

Wednesday, February 21, 2007

Subsonic or ActionPack the zero code DAL

Hi all,

something all the lazy programmers out there have been waiting for :

This is the heaven of dal coding, the only down side is that you need full trust on your web to use its full features (i.e. custom build providers to automatically generate vb or c# classes to access your database structure).

In other words, the people on shared hosting environments, forget it. However if you have a dedicated server, then the world is your oyster and man this tool is great!

No more boring data access code to write, one class per table is generated and allows you to query your data in a very efficient way!

Thanks guys for this... wonder how it's going to compete with LINQ though?


AJAX 1.0 is here and will tranform the web

I am now working closely with Microsoft AJAX extensions v1.0 and I have to say congratulations to them for developing such a cool programming concept.

I am using it everywhere I can and have been able to design things that I have dreamt of years ago without any hassle.

.NET web developers, go there now and watch all the videos, you won't regret it:

Happy programming!