# Saturday, 24 June 2006

You know that your collegue has created a class with interesting method that you like to reuse in your ASP.NET 2.0 web project but your project is in C#. Instead of waisting time to rewriting the whole chunk of code that your collegue wrote you can simply reuse the code. The only need is to create a couple of subfolders, putting your classes, C# and VB.NET, in these separate subfolders and put some extra configuration in the web.config file.

So for example you add these subfolders to the App_Code folder: CSharp and VB.

In the web.config you put these lines in the <compilation> element:


    <compilation debug="true">


        <add directoryName="CSharp"/>

        <add directoryName="VB"/>




Another nice thing about this is that you could also use it to organise your classes somewhat better. For example you can create several subdirectories which hold business classes that belong together and make them known in the <codeSubDirectories> element.

Grz, Kris.

Saturday, 24 June 2006 18:49:25 (GMT Daylight Time, UTC+01:00)  #    Disclaimer  |  Comments [2]  | 

Last thursday I attended a session presented by Jan Tielens in Mechelen on the subject of Office 2007.
The session was dedicated for developers and because I haven't tried it out myself I found the new possibilities of Office 2007 very interesting. Especially the new file formats and the distinction between macro enabled and macro disabled documents are great. I still remember the time that macro virusses became available and the harm they could do to someones computer. Also the files themselves are smaller than in the past because they're, behind the scenes, compressed zip files. So in order to take a look at what's inside you just have to rename the file and add .zip behind the file extension of the document and you can open it with winzip for example. After that you can clearly see that all the data is now inside xml files and there are dedicated subfolders available to hold the embedded data like for example images.

The fact that the data is now xml means that a developer can quite easily manipulate the data, or create documents, with .NET. Especially because the next version will hold extra capabilities to interact with the so called "packages".

Besides the new file formats and what a developer can do with it we also had a demo about how to use the VSTO to create custom task panes or to create custom ribbons.

Well, I hope to get into experimentation on this topic soon because it really looks great to me.

Grz, Kris.

Office | MSDN
Saturday, 24 June 2006 18:30:22 (GMT Daylight Time, UTC+01:00)  #    Disclaimer  |  Comments [0]  | 
# Wednesday, 21 June 2006


I found out, via Jan Tielens' blog, whom found out via Eli Robillard's blog, that you can download a 236 pages free eBook in pdf format about 7 Development Projects with the 2007 Microsoft Office System and Windows SharePoint Services 2007.

So for all you guys and girls interested: get your copy here.

Grz, Kris.

Wednesday, 21 June 2006 15:51:36 (GMT Daylight Time, UTC+01:00)  #    Disclaimer  |  Comments [0]  | 
# Tuesday, 20 June 2006

After months of using the Beta variant of this new incarnation of messenger, and with a rechristianed name that makes it a part of the whole new Live productline, I got my hands on the final bits. Since I installed IE7 Beta 2 I also put http://search.live.com/ as my personal home page. I really dig the AJAXised scrollable overview of the found resources. If you haven't checked it out yet, you really should!

If you want your copy just browse to http://get.live.com/messenger/overview.

Grz, Kris.

Tuesday, 20 June 2006 20:24:26 (GMT Daylight Time, UTC+01:00)  #    Disclaimer  |  Comments [0]  | 
# Monday, 19 June 2006

I like it when I'm in very large solutions with a lot of projects that my Solution Explorer of vs.net highlights the currently opened file instead of searching/scrolling around. In the previous versions this was enabled by default but for some reason Microsoft decided to don't have it as a default in vs.net 2005.

You can however enable this small but helpfull feature by navigating to the menu bar. Click Tools | Options and open the node called Projects and Solutions. You should see a modal window like Figure 1. Just check the checkbox labeled Track Active Item in Solution Explorer and you're good to go.

Figure 1: The options for Projects and Solutions.

Grz, Kris.

Monday, 19 June 2006 21:07:37 (GMT Daylight Time, UTC+01:00)  #    Disclaimer  |  Comments [0]  | 
# Sunday, 18 June 2006

A lot of people, myself included, like to see the line numbers on each line while coding. I find it easer to remember where my code is but also to use the ctrl + g (goto line number) shortcut. By default this feature is disabled but luckely it's quite easy to turn it on.

Just navigate to the menu, choose Tools | Options and this expand the Text editor node in the treeview on the left like shown in Figure 1:

Figure 1: The expanded Text Editor part

There you can choose the All languages node or the node of the language that you're interested in and check the Line numbers checkbox. Click the OK button and you have the line numbers appearing in your source view.

Grz, Kris.

Sunday, 18 June 2006 18:23:51 (GMT Daylight Time, UTC+01:00)  #    Disclaimer  |  Comments [1]  | 

Nullable types in .NET 2.0 are a great asset for many developers. I use them all the time in my current project. However there are some things that you should be aware of. Because they can be filled in or can be null you should perform some extra checks in order to get your code to behave like you would expect it.

I've written some sample code that uses a nullable DateTime endDate. In applications this can be used to denote a period, startDate - endDate with the endDate being as such that it will never expire. In .NET 1.x we would've just filled it up with new DateTime(9999, 12, 31);. With nullable types you can just let it be null and check appropriately.

    1 <%@ Page Language="C#"%>


    3 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">


    5 <script runat="server">


    7     protected void Page_Load(object sender, EventArgs e)

    8     {

    9         DateTime startDate = newDateTime(2004, 5, 23);


   11         // Using a nullable DateTime can represent an occurance that doesn't expire.

   12         // In a database, like SQL Server, you can have this field set to NULL.

   13         DateTime? endDate = null;

   14         DateTime toCheck = newDateTime(2006, 6, 13);


   16         // First example: this test will fail because we check

   17         // a normal DateTime against a nullable DateTime without

   18         // replacing it with something to check against when it's null.

   19         // Note however that this code compiles! It's only not working out

   20         // in a functional logic way because it doesn't do what we would expect.

   21         if (startDate <= toCheck && toCheck < endDate)

   22             LabelEndDateNull.Text = true.ToString();

   23         else

   24             LabelEndDateNull.Text = false.ToString();



   27         // Second example: now we're checking, and replacing it with an appropriate

   28         // value in case it's null, so the test will pass as expected.

   29         // The trick here is to use the GetValueOrDefault() method on a Nullable type

   30         // to replace it with a default value in case it's null.

   31         if (startDate <= toCheck && toCheck < endDate.GetValueOrDefault(DateTime.MaxValue))

   32             LabelEndDateNullButWithGetValueOrDefaultUsage.Text = true.ToString();

   33         else

   34             LabelEndDateNullButWithGetValueOrDefaultUsage.Text = false.ToString();


   36         // Third example: this one's exactly the same as the previous, second, example.

   37         // Only here I'm applying the great ?? operator available in C# 2.0.

   38         if (startDate <= toCheck && toCheck < (endDate ?? DateTime.MaxValue))

   39             LabelEndDateNullButWithCheck.Text = true.ToString();

   40         else

   41             LabelEndDateNullButWithCheck.Text = false.ToString();



   44         // Fourth example: fill up the nullable DateTime with some actual value:

   45         endDate = newDateTime(2007, 1, 1);


   47         // We can see, this is easier when done debugging the code, that the enddate

   48         // now has some actual value and the test will pass.

   49         if (startDate <= toCheck && toCheck < (endDate ?? DateTime.MaxValue))

   50             LabelEndDateNotNull.Text = true.ToString();

   51         else

   52             LabelEndDateNotNull.Text = false.ToString();

   53     }


   55 </script>


   57 <html xmlns="http://www.w3.org/1999/xhtml">

   58 <head runat="server">

   59     <title>Untitled Page</title>

   60 </head>

   61 <body>

   62     <form id="form1" runat="server">

   63     <div>

   64         Enddate = null:

   65         <asp:Label ID="LabelEndDateNull" runat="server"></asp:Label>

   66         <br/>

   67         <br/>

   68         Enddate = null but with GetValueOrDefault method:

   69         <asp:Label ID="LabelEndDateNullButWithGetValueOrDefaultUsage" runat="server"></asp:Label>

   70         <br/>

   71         <br/>

   72         Enddate = null but with ?? check:

   73         <asp:Label ID="LabelEndDateNullButWithCheck" runat="server"></asp:Label><br/>

   74         <br/>

   75         EndDate != null:

   76         <asp:Label ID="LabelEndDateNotNull" runat="server"></asp:Label></div>

   77     </form>

   78 </body>

   79 </html>

The output of this little code sample is:

Enddate = null: False

Enddate = null but with GetValueOrDefault method: True

Enddate = null but with ?? check: True

EndDate != null: True


Take a look at the comment in the code, or better yet: debug it on your own dev machine, to see the subtle difference between the first and second example. The third example's just the same as the second but uses the ?? operator, the one that I prefer in my code because its shorter. The ?? operator, or null coalescing operator, is only available in C# 2.0.

Grz, Kris.

kick it on DotNetKicks.com

Sunday, 18 June 2006 13:01:24 (GMT Daylight Time, UTC+01:00)  #    Disclaimer  |  Comments [0]  | 

I'm probably very late with this but finally decided to join del.icio.us so finally people can also see what I like to read or am interested in.

For people who don't know this service:

del.icio.us is a collection of favorites - yours and everyone else's. Use del.icio.us to:

  • Keep links to your favorite articles, blogs, music, restaurant reviews, and more on del.icio.us and access them from any computer on the web.
  • Share favorites with friends, family, and colleagues.
  • Discover new things. Everything on del.icio.us is someone's favorite - they've already done the work of finding it. Explore and enjoy.

Grz, Kris.

Sunday, 18 June 2006 10:43:06 (GMT Daylight Time, UTC+01:00)  #    Disclaimer  |  Comments [0]  | 
# Tuesday, 13 June 2006

I just found out about the existence of this newly dedicated site: netfx3. After blogging already about the renamed WinFX to .NET 3.0 framework name it seems Microsoft's dedicated to the new naming.

Grz, Kris.

Links | Vista | WCF | WCS | WF | WPF
Tuesday, 13 June 2006 15:55:06 (GMT Daylight Time, UTC+01:00)  #    Disclaimer  |  Comments [2]  | 
# Monday, 12 June 2006

Just saw that Scott Mitchell, of 4guysfromrolla fame, announced that he's busy writing tutorials about working with data in ASP.NET 2.0. You can find the tutorials in the Learn section of the ASP.NET official site among other tutorials like videos's, starter kits, ... Be sure to check out the Working with data in ASP.NET 2.0 tutorials. They're also downloadable in pdf format in both VB.NET and C#.

Grz, Kris.

Monday, 12 June 2006 21:08:05 (GMT Daylight Time, UTC+01:00)  #    Disclaimer  |  Comments [0]  |