Dennis van der Stelt

The most votes generally drown out the best votes

Community

News

  • Addicted to Refactor! Pro

Email Notifications

I read...

I Use...

Tags

Recent Posts

Archives

Season greetings from BloggingAbout.NET

basmallBloggers, visitors and spammer, we have a season greeting for you if you click the link.

Hope everything goes well for you in the new year! 

Season greetings…

Scott Hanselman happy to be inside a Vertigo Player

scotthanselmaninsidevertigoplayer

New era

Tellus logo Since November 1st I’ve switched jobs and am no longer working at Class-A. I’ve had a really good time there and was unaware of the growth someone (like me) could make when you start a career as trainer and coach. Some of my colleagues were the best to work with, both professionally and personally. Thanks to everyone there.

However it’s time to move on for me for various reasons. I’m began a new career at Tellus, a company of about 60 employees. It’s doing some really great and advanced stuff on both .NET development and infrastructure and also has a huge vision and plans for the future of which I hope to be a part of.

I will most definitely not disappear from the .NET community and hope to do a lot more blogging and make an appearance at conferences like before. I’ve already got some plans on how to share some hands on experience with other people, lessons learned from the past. I’d really like to share some insights there, share knowledge and hopefully get some back as well. I’m really excited and will keep you updated.

Zune player in taskbar

 zunetaskbar This is pretty sweet, you can have the Zune player in your taskbar.

On previous version of Windows, I had my media player up there. But now the Zune player has this ability in Windows 7 as well.

If you have the Zune 4.0 software installed you can right-click the Windows 7 taskbar, select toolbars and then select the Zune toolbar. Now whenever you minimize the Zune player software, the icon will disappear and the player will be in the taskbar. The larger image on the left appears when you hover over the minimized player.

On the Windows weblog there’s more information available about the combination of Windows 7 and the Zune software. There are other options available that might interest you.

Zune software updates for Zune 4.0 optimized for Windows 7

Create a custom caching manager for Enterprise Library 4

I wanted to create a custom caching manager for Enterprise Library 4 that did… nothing. I Googled and Binged but could not find a way to temporarily turn off caching completely. And I want that so I can do some performance tests with the websites we have on the server. I don’t want to know how fast my app is, I want to load test the server and see how it performance, with and without caching. So that’s why I decided to create a Caching Manager that did nothing.

The documentation did not tell me much though, and there are some really weird gotchas in there. Here’s the part about the custom caching manager.

caching_documentation

Inherit from ICacheManager and add ‘the following configuration element’. And they’re serious about that part!!! I’ll show you why. Here’s what I did. First, I created a new Class Library and added a class named PointlessCacheManager that inherits from ICacheManager and put the attribute on top of it. I added another one for those who need it, but it’s commented out. This extra class also does absolutely nothing! :) First the custom cache manager.

//[ConfigurationElementType(typeof(PointlessCacheManagerData))]
[ConfigurationElementType(typeof(CustomCacheManagerData))]
public class PointlessCacheManager : ICacheManager
{

    public PointlessCacheManager()
    {
    }

    public PointlessCacheManager(NameValueCollection collection)
    {
    }


    public void Add(string key, object value, CacheItemPriority scavengingPriority, ICacheItemRefreshAction refreshAction, params ICacheItemExpiration[] expirations)
    {
    }

    public void Add(string key, object value)
    {
    }

    public bool Contains(string key)
    {
        return false;
    }

    public int Count
    {
        get { return 0; }
    }

    public void Flush()
    {

    }

    public object GetData(string key)
    {
        return null;
    }

    public void Remove(string key)
    {
        return;
    }

    public object this[string key]
    {
        get { return null; }
    }
}

If you use the CustomCacheManagerData you need the constructor with the NameValueCollection as parameter. The PointlessCacheManagerData uses the default constructor, or you can modify it to whatever you like.

Are we done yet? Maybe almost!!!
Again, if you want to have a custom cache manager that does nothing, you’re done with adding classes and you can skip the next part and continue reading at the configuration part. If you need more, like your own configuration, read on…

Now here’s the second class, with an even lesser implementation.

[Assembler(typeof(PointlessCacheManagerAssembler))]
public class PointlessCacheManagerData : CustomCacheManagerData
{
}

But this PointlessCacheManagerData class also references another class named PointlessCacheManagerAssembler. These two classes are used for reading configuration and initiating the cache manager. Here’s the last class.

public class PointlessCacheManagerAssembler : IAssembler<ICacheManager, CacheManagerDataBase>
{
    public ICacheManager Assemble(Microsoft.Practices.ObjectBuilder2.IBuilderContext context, CacheManagerDataBase objectConfiguration, IConfigurationSource configurationSource, ConfigurationReflectionCache reflectionCache)
    {
        PointlessCacheManager createdObject = new PointlessCacheManager();
        return createdObject;
    }
}

Configuration
app_config_entlib Now comes the fun part. You want to configure the new cache manager in your application. Most of it is pretty easy though. Open the Enterprise Library Configuration application, or open up the application configuration by right-clicking it in Visual Studio, as you can see on the right.

When the configuration is opened (either in the seperate EntLib Config app or in Visual Studio), right-click the configuration node and select “New” and “Caching Application Block”. A new node should be added and under it you should see a node called “Cache Managers” with the default cache manager under it. Right-click the “Cache Managers” node (or folder, if you will) and select “New” and “Custom Cache Manager”. This is where you’ll configure your PointlessCacheManager.

However, and this is a big however. Two even. But only if you used another class than the default CustomCacheManagerData in the attribute on top of your PointlessCacheManager. Because the documentation told you to put “[ConfigurationElementType(typeof(CustomCacheManagerData))]” on top of your custom cache manager. And as I said before, they mean what they say. Although we don’t want to use that class when we implement our own configuration, we need to put the CustomCacheManagerData on top anyway. If you did that and compiled the class, we can configure our custom cache manager.

app_config_entlib_2 You can first give this one a name. I named mine “Pointless Cache Manager”. Note the spaces, the name is nowhere related to class names. Now select the “Type” key so that you can add a value. A small button should come available to select the type in an assembly. I pointed it out in the image on the left. Locate the assembly with the PointlessCacheManager in it on your harddrive. You should get the following image. If not, read on as well.

app_config_assembly

REMEMBER : When you made a change, mistake or anything like this, you need to restart the host of the configuration, to be able to see the changes. In other words, when you loaded the Enterprise Library Configuration application, restart it. When you’re changing the configuration in Visual Studio, restart it. Because it loads the assembly and never refreshes it, so changes aren’t visible until you restart the host application.

Make sure you’ve got the commented out line in the PointlessCacheManager uncommented so that it exactly (!) states what the documentation states. Once you’ve configured it correctly in your application’s configuration (or web.config) you can change it back to where it states that you’re using the PointlessCacheManagerData instead of the CustomCacheManagerData, recompile and work with it.

Now you can switch back and forth between the normal en the pointless cache manager.

SDC 2009 slidedecks and demos

DSC_0130 For me this was my first SDC and I really had a lot of fun. Great discussions with speakers and attendees. And as Dennis Doomen mentioned, the evening was pretty fun as well. I did two sessions, on about Test Driven Development, a basic introduction with some best practices. And also a presentation on Microsoft’s solution to distributed caching, “Velocity”.

Introduction into the TDD Mantra (slides and demo)
So you've heard about Test Driven Development but you're not sure what it is? Not sure if it is what you're doing? And if's "Test Driven", why do people say tests are less important? Why do tests first have to fail? In this session you'll learn what Test Driven Development is really about. About the simplest thing first and growing your application larger and larger. Until TDD made your application into what it should be, instead of what you thought it was going to be.

Distributed caching with Velocity (slides and demos)
It's been some time since Velocity was introduced, and it hasn't gotten the attention it deserved. Velocity is a distributed caching framework which means it can cache your application's data and distribute this over multiple machines for performance, backup, etc. If you want to know how to use Velocity in your project and/or your website, come join me for this session.

If you have any questions about any of these subjects, don’t hesitate to contact me.

Syntaxhighlighter

I’ve tried a lot of tools and addons to use syntax highlighting on my weblog and BloggingAbout.NET in general. I’ve fallen in love with two of them.

The first I use to use for my weblog. But this causes a lot of markup within the code and it can never be changed later on. I still use CopySourceAsHtml for posting in PowerPoint, Word and other tools though. Simply because it’s really, really good and easy to use from within Visual Studio.

SyntaxHighlighter is a set of Javascript that gives your code its color after it’s being displayed, ie. when the page has loaded. The code itself is rendered within <pre> tags and has no specific markup in HTML for the coloring. This makes the highlighting a bit slower, but with the additional benefits that there’s no extensive markup in the code, that the coloring libraries can be updated. Additionally a popup window is displayed for easily copying the code and some other useful buttons.

For installation I’ll redirect you to the official site.

SyntaxHighlighter plugin for Windows Live Writer : PreCode
What makes my life especially easy as a blogger, is this plugin called "PreCode". The plugin fits nicely into Windows Live Writer and with a popup window, a paste and a fix indentation you have some new code layed out on your weblog. Could not be any easier.

This is the end result:

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            for (int i = 0; i < 10; i++)
            {
                Console.WriteLine("Hello world");
            }
        }
    }
}
Devnology & after party (OffTopic)

Today the Devnology meeting with Rob Vens was held at Class-A in Woerden. It was a fun and interesting evening, you can probably read more about it soon on the Devnology site. One thing I have to throw online though is what happened after the meeting. A lot of people stayed to chat about technology and what the future or other languages and platforms might bring us. That’s what Devnology is always interesting for, the bridge that’s being made between all those different kind of developers.

But after a while a few people stayed, like Michel, Stephan, Freena, Frans Bouma and the Devnology ‘board’. We actually got to play some Guitar Hero tunes and almost everyone complained that the game was lagging, but perhaps that was because they just could not play that well. Frans Bouma played for the first time in his life, the especially difficult Satch Boogie by Joe Satriani, together with Michel. Way cool!

Michel & Frans Stephan Michel & Frans Michel & Frans

Adding SharePoint class resources to your feature using WSPBuilder

I was having some troubles adding class resources to my SharePoint feature, while using WSPBuilder. I searched quite some, and here’s what I did to make it work.

First you need to start with a good project. You can build one pretty fast if you create a new WSPBuilder project and add a “WebPart with feature” to the project. Now the WSPBuilder templates should have created a project with the 12-hive folder inside your project where your webpart feature should be specified.

folderstructureIf you want to add a nice .jpg image to your feature, there are two ways. Embedding it in a .resx file (that’s another blogpost) or copying it to the filesystem of the SharePoint server. Of course not manually, but from inside your feature. Here’s how.

  1. Add a new folder and name it “80”
  2. Add a new folder and give it the name of your project
  3. Add the .jpg to this folder, or create subfolders if you’d like.
  4. Add the following code to your webpart to retrieve the image.

Imagine that your project is called “WebPartResources” then you’d have the structure in your project as shown in the image on the right. Right-click the project, build the WSP and you should have the roughly the following manifest.xml inside your .wsp file.

<?xml version="1.0" encoding="utf-8"?>
<!-- Solution created by WSPBuilder. 7/23/2009 10:46:15 PM  -->
<Solution xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" SolutionId="c8d22333-f09b-4819-b026-a6cb7d64b41a" ResetWebServer="True" xmlns="http://schemas.microsoft.com/sharepoint/">
  <Assemblies>
    <Assembly Location="WebPartResources.dll" DeploymentTarget="GlobalAssemblyCache">
      <SafeControls>
        <SafeControl Assembly="WebPartResources, Version=1.0.0.0, Culture=neutral, PublicKeyToken=6763c0814d065309" Namespace="WebPartResources" TypeName="*" Safe="True" />
      </SafeControls>
      <ClassResources>
        <ClassResource Location="dennis.jpg" FileName="dennis.jpg" />
      </ClassResources>
    </Assembly>
  </Assemblies>
  <ApplicationResourceFiles>
    <ApplicationResourceFile Location="WebPartResources\dennis.jpg" />
  </ApplicationResourceFiles>
  <FeatureManifests>
    <FeatureManifest Location="WebPartWithResources\feature.xml" />
  </FeatureManifests>
</Solution>

After deploying it, you should be able with the following code to retrieve the image from this folder, although version and publickeytoken could possible change! :-)
C:\Program Files\Common Files\Microsoft Shared\web server extensions\wpresources\WebPartResources\1.0.0.0__6763c0814d065309

SPWeb currentWeb = SPControl.GetContextWeb(Context);
Type currentType = this.GetType();
string classResourcePath = SPWebPartManager.GetClassResourcePath(currentWeb, currentType);

Image image = new Image();
image.ImageUrl = classResourcePath + "/dennis.jpg";
Quickstart tutorial into Enterprise Library logging

How do you go about logging with Enterprise Library with the following line

Logger.Write("Hello world");

I came up with this post because I explain Enterprise Library logging to a lot of people, in a very short time. You can probably talk about logging and Enterprise Library for a long, long time. But I just want to introduce the very basics of logging. When a new developer starts working at a customer or students in my class want to know, this is the shortest possible story I tell them. That’s why I decided to write this down, as it’s still information people tend to forget easily.

I’m talking about Enterprise Library 4.1 and this is what I’ll explain:

  • Adding the necessary resources (assemblies, dll files)
  • Adding and understanding minimal configuration.
  • Logging information with and without a specific category.

Again, I could talk about priorities and more, but this is just the basics. For more information I’d redirect you to the Enterprise Library manual on logging.

Adding necessary resources

When you’ve installed Enterprise Library 4.1 correctly, you should have the assemblies in your “Add Reference…” dialog under the .NET tab. If not, you can always add them from the folder C:\Program Files\Microsoft Enterprise Library 4.1 - October 2008\Bin or from C:\Program Files (x86)\Microsoft Enterprise Library 4.1 - October 2008\Bin if you’re running on a 64bit machine.

Sidenote : It’s always best to copy the necessary assemblies to a project specific \lib\ folder so that everyone can use your logging solution without installing Enterprise Library. This also goes for the build server, which should obtain the assemblies from source control.

addreferencedialog

In the above image you can see the “Enterprise Logging Application Block” we should add. In Visual Studio this is the only reference you need to add. After you’ve compiled your project however, you’ll notice additional assemblies being added to the /bin/ folder. It’s out of the scope of this article, what these assemblies do. But the following assemblies are the minimum you need to use Enterprise Library logging. If you have /lib/ folder in source control, put these assemblies in, for the build server to correctly build your projects.

  • Microsoft.Practices.EnterpriseLibrary.Common.dll
  • Microsoft.Practices.EnterpriseLibrary.Logging.dll
  • Microsoft.Practices.ObjectBuilder2.dllEditConfiguration
  • Microsoft.Practices.Unity.dll

Adding minimal configuration

If you haven’t, first add a web.config or app.config to your application. If installed correctly, right-click your configuration file and select “Edit Enterprise Library Configuration” as shown on the right in image 2.

InitialConfigThe Enterprise Library configuration tool will be opened. If not, run the tool from the start menu or locate it in the above mentioned folder. After opening it, you should see the empty configuration, as shown in image 3. There’s already a connectionstring in the Data Access block, which is ‘inherited’ from machine.config.

In image 3 you can see an arrow where you should right-click and select “New” and “Logging Application Block”. When the configuration is added, these are the folders that are added

  1. Filters
    I won’t discuss these, but they’re not too difficult to understand either.
  2. Category sources
    Everything you log in your application, falls under a category. When you don’t specify a category while logging, the default category is used. You can see the default category added right now is called “General”.
  3. Special sources
    When Enterprise Library tries to log something but it doesn’t work (for example you try to log to the database, but it can’t find the database) or it can’t find a category you specified, this is the place to configure what should happen then.
  4. Trace Listeners
    If you want to log to the database, a file, eventlog or anything else, you need trace listeners. By default trace listeners are added for logging to database, file, email, eventlog, msmq, wmi and more…
  5. Formatters
    You need formatters to… well, format your logging messages.
    We’ll start with these.

Formatters

FormatterTemplatePropertiesOpen up the “Formatters” folder and select “Text Formatter”. In the properties pane (press F4 if it’s not there or select from the menu “View” and “Properties Window”. In the properties pane (or window) there’s a property called “Tempalte”. Select its value and press the button on the site as shown on the right.

A new dialog window should open with the current message template. As you can see there’s a lot of data there. The minimum message you can use should probably be something like below. When logging to, for example, a database or you’re tracing a lot of messages for some reason, this is probably easier to digest. You can use a cool tool like baretail to read the messages while they’re being written to the logfile on the server. When you’re logging exceptions or other information, you probably want much more detail. At the bottom of the dialog or the possible tokens you can insert. For now, leave it like it is.

FormatterTemplateEditor

However, do rename the formatter from “Text Formatter” to “My Formatter”. Now right-click any node in the configuration editor and select “Validate”. You’ll see everything validates, even though you just changed the name of the formatter. That’s how cool Enterprise Library is. ;-)

Trace Listeners

We’ll add a new trace listener as the “Formatted EventLog TraceListener” can give problems on a server because the account that’s trying to log messages isn’t authorized to write into the eventlog. Right-click the “Trace Listeners” folder and select “New” and “Rolling Flat File Trace Listener”. In the properties pane, rename it to “Rolling Flat File”. Change the filename so that it will log to a specific directory. I normally use something like “C:\Logging\ProjectName"\”. You can already specify a filter here, but we’ll leave it at “All”.

For the formatter property you’ll have to select “My Formatter”, which is the text formatter you just renamed. Also notify the other properties available. You can specify to use a time interval to create a new logfile, or a size interval. Set it to a small size, something like 1Kb so you can easily test what will happen.

Categories

Let’s add a new category and set that category as default one. If you do so, it’s probably best to remove the “General” category, as most people will think that will be the default. Create a new category called “DefaultCategory”. Select the “Logging Application Block” folder and in the properties pane select your new category to be the default one.

Right-click your new “DefaultCategory” category and select “New” and “Trace Listener Reference”. In the properties pane, change the “ReferencedTraceListener” to be your “Rolling Flat File” trace listener.

Logging information

You’re now done with the configuration. Save it and go to your code. Enter the following line somewhere in your code:

Logger.Write("Hello world");

Now go check your configured folder for the file. If it’s not that, check the eventlog anyway, as Enterprise Library might have failed and maybe has written the info there. This worked for me, as I ran into this read or write protected memory error when creating this article.

Azure pricing

So finally they released some information on Azure pricing, or the Azure Business Model as it’s called…

First, it’ll be commercially available from PDC09 in LA this year.

Windows Azure SQL Azure .NET Services
- Compute @ $0.12 / hour - Web Edition – 1GB @ $9.99 Messages @ $0.15/100K message operations , including Service Bus messages and Access Control tokens
- Storage @ $0.15 / GB - Business – 10GB @ $99.99
- Transactions @ $0.01 / 10K  

Bandwith on all three will be charged at $0.10 in and $0.15 out per GB.

Customers have said that consumption based pricing as stated above might give unpredictable results. I can already imagine us opening up the slider and spend tons of computing hours, storage, etc. At PDC09 other options should be presented.

With going prices, if I would host BloggingAbout.NET on Azure, that would probably mean around $ 350,00 per month. With one VM we’d use 24 computing hours a day; our database hasn’t reached the 10GB yet, but is way over the 1GB limit of the web edition. Although I can guess other companies find $ 350 a month pretty cheap, considering they don’t need infrastructure people running around, I think I’ll stick with my own server! :-)

Re-inventing Programming

Just subscribed to the next Devnology meeting. This one will be an expert meeting. Normally Devnology is all about communication and sharing experiences and knowledge, but this evening Rob Vens will be speaking about Re-inventing programming. At the end there’s room for discussion though and it promises to be very interesting.

The event will be hosted at Class-A in Woerden. More information about the event can be found at the Devnology site, where you can also subscribe to the event. Seats are limited so be quick if you want to join!

SQL Data Services update

The Windows Azure and SQL Data Services team have been busy. Workflow was removed from .NET Services until they can support Workflow 4 and Access Control and the Service Bus got minor updates. Read more about it here.

The SQL Data Services team has unfortunately not released anything yet, but they did gave us an update on their weblog about what they will support in version 1. From what I can quickly see is that they’ll support most functions to be able to create tables, modify data and retrieve it using the standard functions CREATE TABLE, SELECT, JOINS, Transactions, etc… Things that’ll be removed are at least everything that has anything to do with the physical machine, because everything will be hosted and maintained by Microsoft.

Read more on SQL Data Services supported features here on the SDS Team Blog.

Twikini, the mobile twitter client

Twikini_Theme_HTCBlack[1] I’ve owned a Windows Mobile for some time, currently the HTC Tytn which sure is up for replacement. But I’m really waiting for the HTC Touch Pro 2 or the HTC Hero or something. With internet on it, it’s great to have the ability to check your email, search the internet when you’re waiting or be able to find customer addresses or something. And of course the ability to tweet about what you’re doing.

For that I’ve been using Twikini for some time, and I love its features. It’s really fast, as it’s written in Native C++ for maximum performance. The menu is also laid out very well and you have the ability to create a tweet and add a twitpic with your camera while you’re at it. This ability makes it wonderful to tweet about special events with family or friends and when you see something exciting happening on the road.

Trinket Software, creator of Twikini also has some other great applications. When you buy Twikini for only $ 4.95 you’ll get an additional application for free. Or, if you blog about Twikini like I just did, you get it for free! :)

More info and downloads right here : http://www.trinketsoftware.com/Twikini

Is Azure ready for production usage?

Last week at the SDN Event in Houten, I presented a session on Windows Azure and how you can develop applications on it. How it differs from developing for servers that run on premises. After the presentation, the question was asked if developing for Azure was a wise idea, as some stuff did not seem production ready.

After thinking a bit more about this, I believe the person based his question on the fact that I talked about two subjects

  • Creating Azure Storage tables in the cloud and not being able to detect whether they’re there already.
    Read this article from Steve Marx for more info, although since the article it changed a bit. Blog coming up on that.
  • Deleting all entries in a table (truncate table) isn’t (directly) possible via the API.
    You’ll have to read every entry and delete each of them manually.

I’ve talked about this and perhaps because of this (or me) people got the impression Azure is not production ready. Maybe these issues will be solved, maybe not. These are all API related issues though and have nothing directly to due with Azure being production ready.

From what I’m observing, the Azure team is working really hard to get Azure working and perhaps spends less time on tooling and API. I’m very sure these will come in the near future, but we can already develop for Azure and it’s less important than getting a complex technology like Azure ready for release. And that’s what I am sure of, that the team is making sure Azure will work.

Is Windows Azure production ready?
The short and simple answer is probably no, because Windows Azure has not been officially released yet. But in my opinion it’s definitely worth checking out, because –as I said during the presentation- Microsoft is investing heavily on it. Invest in Azure now and reap the benefits of it sooner or later. It is expected that cloud computing will be as common in usage, as plugging in an electric device and instantly getting power is common right now.

More Posts Next page »