Category: WPF
Posted by: Mike
Although the WindowsFormsIntegration dll provides some functionality to provide interop between winforms and WPF, there are some other possibilities. ElementHost allows you to host WPF elements in your winform app and WindowsFormsHost allows you to host winform controls in your WPF application. But what if you would like to add a complete form to your winform app? What I did was to write a WPFRuntime class which helps you to display WPF windows from within a windows application. The class starts a new thread that runs the WPF application runtime with the help of a hidden window. Then you have some methods that ask the WPF application dispatcher to show a window of the type you provided. This allows you to create new windows entirely in WPF and still host them in a legacy winform application. The class might need some extensions to provide parameters to a window for instance but that is for a later time perhaps. You can find the demo code here
Category: WPF
Posted by: Mike
When you use blend on a HP computer, it could happen that your designer can't show any XAML files. You always get an error like 'The name "..." does not exist in the namespace
"http://schemas.microsoft.com/winfx/2006/xaml/presentation"'. After searching for quite a while I discovered this was due to an environment variable. Some HP systems set a PLATFORM environment variable to e.g. MCD or HP. This causes MSBuild (and for that matter also blend and Visual Studio) to use that platform as the target platform in stead of 'Any CPU'. Remove the environment variable and the problem should be resolved.
Category: WCF
Posted by: Mike
Today I was running a demo on WCF duplex communication with wsDualHttpBinding. My demo was pretty basic so it was created through standard stuff. I created the demo in VS2005 running on Vista. I distributed the sample and when people ran it on Windows XP the client terminated with the error: "HTTP could not register URL
htp://+:80/Temporary_Listen_Addresses/ because TCP port 80 is being used by another application.". At first this seemed odd to me because I was wondering why the client tried to communicate on port 80. I am/was used to programming with sockets and remoting where client picked a random free port to establish communication from server to client. Apparently WCF creates a HTTP socket on port 80 to service client callbacks. Clearly the client was conflicting with IIS on XP while this was not the case on Vista. This behavior is due to the nature of the architecture of IIS 6.X and IIS 7. All HTTP-protocol traffic in IIS6.X/7 gets routed through the http.sys, kernel mode component. Even when you create a selfhosted application or client which uses http, the traffic gets routed through http.sys. http.sys dispatches all requests to a worker process, so all that http.sys had to do is send the request to our client application in stead of the default w3wp.exe IIS worker process. XP still uses IIS 5.X, whom doesn't have this kernel architecture, so trying to open an additional socket on port 80 clearly conflicts with IIS 5.X. To resolve this problem you have to provide a clientBaseAddress in the binding configuration on the client.

null

Also testing multiple clients on XP this way isn't really feasable. You will have to provide the clientBaseAddress in code and associate a different port with each client.

For more information see the hosting services article and the duplex services article on msdn
Category: ASP.NET
Posted by: Mike
In my previous post you see why I use DotNetNuke for some projects. One thing I came across was the poor support with respect to multilanguage websites. So I started creating some modules to improve this. The first thing I created was a HTML Text Module that shows another text depending on the language that is selected. I used the default HTML Text Module as a reference and moved on from there to make it support multiple languages. The principle is easy, put the module on a page and then you can easily edit the text in different languages by selecting the desired language in a dropdownlist. The available languages depend on the installed cultures. You can find the bits here

I have no install package yet so it is source only: put the files in the corresponding folder in the DotNetNuke project and create the table with the script in the 03.01.00.SqlDataProvider file. Configure the module in DotNetNuke and off you go. Currently the module only supports english and dutch (my core language skills are programming languages sorry). But if you send me the adjusted resource in your language I will add it in the package.
Category: ASP.NET
Posted by: Mike
Recently I was looking for a free CMS in ASP.NET. I came across 3 valuable candidates which I tested ... These are:

- AxCMS
- Umbraco
- DotNetNuke 4.X

I tested other products as well but they didn't seem to meet the minimum requirements I was looking for. So here are my 2 cents on those 3 systems.

AxCMS was the first one I tested. Setup went pretty smooth and I got it up and running in no time. Once I started working with it, I noticed that AxCMS offered great flexibility and high level functionality out-of-the-box. But the advanced features come with a price. I, as a developer, quickly adopted the CMS but while I was playing around, I quickly started asking myself: "Will the average user find this suitable for his needs?". I tend to think the answer is no. Why? Well I guess the system is a bit to complex to use if you have no IT background. For the average professional webmaster, I would say this system is great!

The second one was Umbraco. I can be brief on this one. I like it, it's simple, easy to extend and setup went flawless. The only reason why I wouldn't use it at this point in time, is that it didn't seem mature enough e.g. some translations where very unclear for the end user. But I will keep track of Umbraco for sure and there is a big chance I will actually use it some time in the near future.

Last but not least DotNetNuke. Since it is on the ASP.NET website as a resource, I consider it a Microsoft "product". And I have to admit it, I'm a huge Microsoft fan :-). So you might think why didn't he use DotNetNuke in the first place. Well I deliberatly tried to avoid it, this time. I was seriously looking for an alternative for this and I hate to say I failed. It took me a while to get DotNetNuke up-and-running and some collegue's of me agree with me on this point. But once installed, I liked it's simplicity and ease of use and for me it was the best option for the moment. Extensions can easily be created with the use of user controls. So, are there no drawbacks at all? Sure... There are some things in the API which I consider an example of over-architecturing. Nearly everything is abstracted etc. This is certainly the case with navigation. While everything is beautifully globalized, creating multilanguage websiteq appears a hard thing to do out-of-the box and I didn't find many free resources on the internet to help you with this in an easy way. (I'm a belgian and as you may have heard some people around here speak different languages which makes multilanguage sites a must have thingy.)

So what's my conclusion? If the people who have to administer the website are IT-people use AxCMS for sure. If that is not the case then use DotNetNuke for the moment, but consider Umbraco as a great alternative with some opportunities for the future... This is if you require ASP.NET of course... ;-)
Posted by: Mike
Since the moment I first heared of the Guidance Automation Extensions (GAX) for Visual Studio, I considered this a very usefull feature. GAX and especially GAT (Guidance Automation Toolkit) allows you to create packages for Visual Studio that help the programmer in executing repetitive tasks as well as respecting certain guidelines. GAX/GAT also was supposed to make the delevopment of certain Visual Studio extensions a bit easier. Creating such packages though still remains a nifty job in my opinion but it offers great perspectives once you get a hold of it. One of the example Guidance packages is the Data Access Guidance package (this was renamed to Repository Factory on codeplex). The Data Access Guidance package helps you create Data Accessors based on database tables and stored procedures, with the use of Enterprise library. This package has some drawbacks the way I see it. First it generates rather complex code based on factories etc. which isn't always interesting when you are usually creating smaller projects. Second, it is tightly coupled with SQL-Server (at least from my point of view), again usefull when you only use SQL-Server. Third it uses Enterprise Library, great stuff, but way to much overkill again for some smaller projects.

So here is my solution. I took the Data Access Guidance package and reworked it a little bit:

- It generates simple Data entity and DataAccessor classes
- It uses generated or custom SQL statements in stead of stored procedures
- It has a rather generic Data Access class that makes use of the generic Data classes from System.Data.Common, so you can choose your preferred database provider type using the configuration file
- Although it currently only works for SQL-Server as well, is has a pluggable architecture that allows easy emplementation of other database engines like MySql or Access

You find the source code to this package here

The package installer works with VS 2005 and GAX 1.3 (july 2007). It might work on VS 2008 but I didn't have the time to rebuild and test it yet.

Following links should help you install it and understand the code:

- Repository factory on codeplex
- Guidanceautomation.net
- Jelle Druyts blog on creating guidance packages
- Guidance automation website

Hope you enjoy it.
Posted by: Mike
I'm very fond of creating web application projects in Visual Studio rather then web site projects. While I tend to think web applications offer a lot of advantages with respect to deployment, etc. (Otherwise why would microsoft have brought it back into VS2008) It also has some disadvantages for instance the custom profile class doesn't get generated anymore. On codeplex there is a custom add-in for VS 2005 that solves this shortcomming to some extend. You can also find a related article on Scottgu's blog. Sadly at this point it only works for VS 2005 so I've modified it to work on VS2008 (even the beta 2). Hope it helps some people. You can download it here

27/11: My own blog?

Category: General
Posted by: Mike
A while ago I've started creating a blog. But soon I was thinking "Are there not already enough blogs...", so I left the idea. Over the recent years I came across many programming issues, which were not always that easy to solve. Last week I was demonstrating something to a group of students and they said you should put this online a lot of people are asking for this. I was wondering where I could put all those bits untill one of them said "Start a blog". So here I am again, setting up a new blog...