MICHELVANDERVLUGT.NET RSS 2.0
 Wednesday, June 20, 2007

Last week was the biggest Microsoft developer event in the Netherlands, the DevDays 2007. It was a two day event with a lot of sessions (50+) presented by some of the greatest names in the world of software development like Scott Guthrie, Dino Esposito and Ingo Rammer, to only name a few. Together with this event there was also the ReMIX, which added another 15+ sessions. Unfortunately it was only possible to follow 9 of the sessions plus the keynote, making it very hard to choose...

One of the biggest things during this event was the presentation of Silverlight, the cross-browser and cross-platform .NET plug-in for Rich Interactive Applications (RIAs) on the web. Scott Guthrie presented it during the keynote and in two full sessions on the second day, explaining  what is in it now and what is planned for the near future. What I've seen from Silverlight (former WPF/E) until now is really incredible! Especially the demo of the project TopBanana, a video editing tool from Metaliq.com entirely built with Silverlight. At this moment Silverlight is at the 1.0 beta / 1.1 alpha stage and is cross-browser and cross-platform only for Windows and Mac, a version for Linux is planned by the Mono project. According to Scott it is not recommended to start a business project with Silverlight at this moment however. You'll be missing a lot of controls that you might expect out-of-the-box but which are just not in yet. They will definitely be included though with next releases later this year.

Another main thing of the event where the topics surrounding the .NET Framework 3.0. Many very interesting sessions covered the various aspects around WPF, WCF and WF. The demonstration of the air-hockey game by Mark Miller was real fun. He build this game where two instances of the application can connect with each other using WCF to play. The user interface of the application was built with WPF.

Of course sessions about the new .NET Framework 3.5 and the new Visual Studio Orcas (VS 2008) where not missing. The new VS2008 will include some great new features like multi-target support (.NET 2.0, 3.0 and 3.5), built in ASP.NET AJAX, improved and new designers like a split-screen HTML designer and the new CSS manager, improved javascript debugging and javascript IntelliSense (very handy). And not to forget, LINQ. The major new language feature of the 3.5 framework, making it possible to query various datasources in one unified way.

More information about the event including the slides of all the presentations can be found here.

Wednesday, June 20, 2007 8:45:26 PM (W. Europe Standard Time, UTC+01:00)  #    Comments [10] -

 Monday, June 18, 2007

Test Driven Development is a great thing in software development as it makes it possible to verify your code very easily during development and when you have to make changes. However, it is not always easy to write solid unit tests when external influences are involved. 

For example, in case of Web Services you might want to avoid the actual Web Service calls in your unit tests for reasons like availability, performance, predictability, ... of the Web Service. In my case I had to avoid the Web Services because I couldn't rely on the information they returned (the content of the underlying ERP database was out of my control).

To solve this problem for the unit tests and get a predictable response that can be tested there are basically two solutions:

  • Create a dummy Web Service that replaces the actual Web Service;
  • Replace the proxy of Web Service in the project by a dummy proxy.

In my project I choose for the latter on, based on a technique that is described in a blog post by David Waddleton. The trick that makes this technique possible and fairly easy is that the generated proxy is a partial class (.NET 2.0). This makes it possible to define an interface on the generated proxy (without changing it) by writing your own partial class. The service consumer can now communicate with the Web Service using the interface instead of directly to the Web Service. At this point you are free to replace the Web Service implementation for a mock object during the unit tests using some form of dependency injection.


ClassDiagram

Note: In the picture above the class MyService is displayed as two classes for clarity of the concept, in reality this is only one class implemented in two cs files.

Creating the interface might seem to be a lot of work, especially for larger Web Services, but it can easily be generated using the refactor tool [Extract Interface] on the proxy class defined in Reference.cs. The implementation of the partial MyService class stays empty, it only defines the interface IMyService (the implementation of IMyService is in the generated proxy).

For dependency injection I've used a simple factory class that either instantiates the Web Service or, in case of the unit tests, an instance of a mock object defined in the web.config.

However, as easy this is in C# 2.0 it cannot be implemented the same way in VB.NET. The reason is that VB.NET doesn't support implicit interface implementation, you have to define the interface implementation explicitly using the Implements keyword:

Public Function DoSomething() Implements IMyService.DoSomething End Function

This is too bad because you either have to alter Reference.cs (which you shouldn't because when you update the web reference you loose the changes) or implement new properties/functions in the otherwise empty class MyService and map them to the Web Service, which is a lot more work. 


The source code can be downloaded from here: WebServiceMockTechnique.zip (62,52 KB)

Monday, June 18, 2007 7:15:04 PM (W. Europe Standard Time, UTC+01:00)  #    Comments [9] -
 |  | 
 Sunday, June 17, 2007

In my last post I explained the problems I had running dasBlog in a Partial/Medium Trust environment. There where two problems left, the web.config sections UrlMapper and httpCompress had to be removed and the admin pages return errors.

The first problem can be solved easily by adding the attribute requirePermission="false" to the section declarations (only .NET 2.0), including newtelligence.ControlImages:

<section name="newtelligence.ControlImages" type="newtelligence.DasBlog.Web.Core.WebControls.ControlImageModuleSectionHandler, newtelligence.DasBlog.Web.Core" requirePermission="false"/> <section name="newtelligence.DasBlog.UrlMapper" type="newtelligence.DasBlog.Web.Core.UrlMapperModuleSectionHandler, newtelligence.DasBlog.Web.Core" requirePermission="false"/> <sectionGroup name="blowery.web"> <section name="httpCompress" type="blowery.Web.HttpCompress.SectionHandler, blowery.Web.HttpCompress" requirePermission="false"/> </sectionGroup>

The second problem is caused by a line in site.config. In this file there is an entry that references the assembly newtelligence.DasBlog.Web with a public key token of null. However, since all assemblies are now have a Strong Name the public key token has to be filled.

<EntryEditControl>newtelligence.DasBlog.Web.FreeTextBoxAdapter, newtelligence.DasBlog.Web, Version=1.9.6264.0, Culture=neutral, PublicKeyToken=123ABC</EntryEditControl>

The public key token can be retrieved from a dll using the sn.exe utility in a command shell:

sn -T newtelligence.DasBlog.Web.dll

At this moment all seems to be working, finally...

Sunday, June 17, 2007 8:14:11 PM (W. Europe Standard Time, UTC+01:00)  #    Comments [14] -

 Saturday, June 16, 2007

... and that was not easy.

My first experience with dasBlog was a setup on Windows Vista, this didn't work. The main problem I ran into is described in a blog post of Daddy Starr and might be fixed in the next version of dasBlog, which will be released very soon (DasBlog June 2007 Release). So instead of using one of the latest daily builds I've installed the official community edition (version 1.9.6264.0) on a Windows XP virtual machine and configured it. Now I only had to wait for my host provider creating my new domain, thinking that a copy to my host provider would be all.

I was terribly wrong... The environment of my host provider is secured using Partial Trust and Code Access Security, and that is not a good thing when you want to run dasBlog out of the box. The only was solving the problem was downloading the source code and make the following changes:

  • Remove the usage of XmlNamespaceUpgradeReader to deserialize configuration files like site.config. The implementation is not allowed with Medum Trust and it doesn't seem to be quite necessary (anymore);
  • Compile all the assemblies, including all referenced, with a strong name and the attribute AllowPartiallyTrustedCallers.

Now it ran on my XP box with a medium trust but still not at my host provider, I still got security exceptions. To get it finally running I had to remove sections UrlMapper and httpCompress from the web.config. What the consequences will be exactly and why they are not allowed I don't know yet, I will figure it out later. For now the 'outside' of my blog runs, although I do experience some problems with the administrator pages after logging in.

BTW. The theme I use is 'business' from a daily build. This theme is designed by Christoph De Baene (delarou), who has done a great job I think.

Saturday, June 16, 2007 7:03:19 PM (W. Europe Standard Time, UTC+01:00)  #    Comments [10] -

Archive
<June 2007>
SunMonTueWedThuFriSat
272829303112
3456789
10111213141516
17181920212223
24252627282930
1234567
About the author/Disclaimer

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2013
Michel van der Vlugt
Sign In
All Content © 2013, Michel van der Vlugt
DasBlog theme 'Business' created by Christoph De Baene (delarou)