May 2006 - Posts
Since a few weeks I'm a heavy fan of NLog as alternative to Log4Net and Enterprise Library. I find Log4Net not simple enough and Enterprise Library is great but has become internally quiet compex (with its dependancy injection inner workings) and for logging it doesn't compare to NLog.
Yesterday a new tutorial has been written which will give you a pretty good idea what it is.
Introduction
In this post I want to share with you a mini framework I developed recently. In one of my projects I had to work quit heavily with Windows Services (NT Service). The mini framework is built using a State Design Pattern. Below I'll briefly describe the state diagram of a Windows Service and then I'll delve into the makings of the mini framework.
The windows service
A Windows Service can be in a started, stopped and paused state. When going from one state to another is called a transition, for example stopping is used to go from the started or paused state to the stopped state. The following image shows the different states and transitions used in a Windows Service:

The yellow boxes are the different states and the green boxes are the transitions. The arrows from the states to the transitions the actions from a certain state. For example, when the service is in a Halted state, the action Start will result in the transition Starting, when this transition is Completed it results in the Started state.
The making of
For the making of the mini framework, I decided to write it in this article, because it would make this post far too long.
Download the Visual Studio 2005 solution here.
enjoy...
a colleague at work pointed me to a very nice (yet another) tool from Red-Gate software, called SQL Prompt.
Instead of creating another editor, they managed to enrich current SQL editors with intellisence features. These products are supported:
- Microsoft Query Analyzer
- SQL Server 2005 Management Studio
- Visual Studio 2005
- Visual Studio .NET 2003
- SQL Server 2000 Enterprise Manager
- UltraEdit32
The application runs in the background (little icon appears in the system tray) and detects when you start working in one of the editors.
In my test with SQL Server 2005 Management Studio, the intellisence sometimes disappeared. So, I could say it's not rock solid, but it is surely promising.
The download is free up to September 2006.
When building applications in multiple languages, we can use todays .NET 2.0 features based on resx files. In web applications Visual Studio offers integrated support for localizing the content.
However, the problems lies also more from a process perspective where creating and maintaining these resources is more than opening the resx file in visual studio. Often companies have non-technical translators that can't use Visual Studio. Additionally they need the right tools to follow up their translation work etc.
Secondly, companies want to reuse their translations and want to use a standard base dictionary. This is not something that is provided when working with resource files.
The solution is always a buy vs build approach.
Buy (and implement):
Today 10 to 15 players are on this market that offer complete solutions of the translation and localization process. Prices ranging from € 1.000 to € 10.000.
The next article shows the review of most of these products: http://www.softreviews.org/Localize.html#feat
Build:
Alternativly, you can build your own system. I know I wrote an post on localizing ASP.NET applications, but I never continued expanding the idea. On the other hand Karl Seguin wrote good articles about it on codeproject:
Part 1: http://www.codeproject.com/aspnet/localization_websites.asp
Part 2: http://www.codeproject.com/aspnet/LocalizedSamplePart2.asp
Part 3: http://www.codeproject.com/aspnet/MultilingualWebsites3.asp
Hi,
For some time now, I'm a dedicated user of Interfaces in my code. I really like to develop using Interfaces because it offers a loosely coupled integration between my components.
However, I find them having one minor drawback, that is, they don't support initialization as constructors do for classes. When I define an interface and want all objects that implement this interface to have an initial state, then I typically add an Initialize method on this interface.
interface IWork
{
void Initialize(string jobName);
}
Having an Initialize method is not that hard to understand for a developer that implement this Interface. Secondly a developer always has to implement all members, so you can be sure a class always has a "certain" implementation.
The problem is more at the client side (client as in code that uses the class), a constructor can be something that is enforced by the class upon its clients. But this is not something you can enforce when working with interfaces. Of course the class could have a constructor on its own, but then this is not regulated by the Interface.
Secondly the Initialize method has - as ex VB developer - a rather unfortunate connotation. In VB we didn't had even constructors, so we had to rely on an Initialize method. However, back then we had to write code to check if the Initialize method was called and if it was forgotten, we had to throw an exceptions (erh, "raising" an error)
Since an Interface defines all operations a class must implement, I would find it logically that we similarly could define its constructors. This way, having a specific interface could enforce the implementation of a certain constructor. This statement however imposes one problem, constructors share the same name as its class, so that's pretty difficult for an Interface to do. Theoretically, we could use the Interface name for this purpose like:
interface IWork
{
IWork(string jobName);
}
Unfortunately this is only theory, but it would make a small difference, at least for me.
Hi,
I did a rather non-conventional migration from .Text 0.95 to CS 2.0. Since our site is hosted, I've chosen to download all data locally. From that data I started the upgrade path from 0.95 -> 1.1 -> 2.0. At the I had a local updated DB. In the meanwhile we moved dotnet6.com from hosting provider, so the best way I though to get the data online on this new hosting package, was by making a difference script. I made this script with red-gate software and applied the script to the online database. The drawback for this approach was that I inserted the data directly into the tables and therefore skipping the search-indexing process.
So, I needed a way to re-index the content and luckily I found the answer on the forum of CS here: http://communityserver.org/forums/thread/517584.aspx.
Hi,
Finnaly I've succeeded into upgrading the dotNet6.com community to the latest release of Community Server. I'm really excited about this new release because it is so much better than the .Text 0.95 we used before.
The upgrade path was pretty painfull but the result is rewarding. Hopefully my fellow dotNet6 m8's will assist in the fine tuning of this community. Ken, hope you can help us out here on the graphical part, since I just thrown our logo's e.a. on the site without any estethical consideration.
One major benefit is that we can now receive back comments on our postings since that was a serious lack in the previous dotNet6 installation. Not that it wasn't possible, but somehow I magically screwed things up :S.
Hope you enjoy the result.
When you use MSBuild based on a solution file, you won’t be able to generate Xml documentation for the projects included in the solution. To generate Xml documentation you need an MSBuild definition file (.proj) where you specify for each Target (per .NET project in the solution) that you want to include Xml documentation.
There are two ways to create a MSBuild project file:
-
Type in by hand
-
Generate it using the undocumented environment variable “MSBuildEmitSolution=1”.
To generate the MSBuild project file as mentioned in step 2 above follow these steps:
-
go to the command prompt
-
go to the location of the MSBuild.exe for example “C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\”
-
type “SET MSBuildEmitSolution=1” to set the environment variable
-
type “msbuild.exe c:\mysolution.sln”
After these steps you will have an MSBuild project file. When opening this file you will notice some “Target” nodes containing MSBuild Task elements. Search for the Properties attribute of these MSBuild elements and add:
; DocumentationFile=$(MSBuildProjectDirectory)\output\nameofyourproject.dll.xml
Additionally specify the output location of the build process by adding another property:
;OutDir=$(MSBuildProjectDirectory)\output\
Pay attention that you add a trailing backslash to this value.
When using MSBuild.exe with this project file, you’ll find both the .net assemblie(s) and Xml documentation file(s) in the output directory. This can then be consumed by NDoc or alike.
Hi all,
It's been a while since I posted on dotnet6, guess I could say it has been bussy lately. Anyway, for the new project I'm working on, our team has to develop a new eCommerce application. Since this is not my first anymore, I figured that today we shouldn't handcode everything anymore. Especially most of the DAL code which is so boring and errorprone to punch in. So, today we have on the one hand these amazing ORM's (*) which offer framework assistance and on the other hand, we have pure code generators.
Unlikely hundreds of discussions exist out there that argument the pros and cons of ORM's versus Code Generators, However, I'll focus this post on code generators, in specific CodeSmith.
I'm familiar with CodeSmith for a long time, but somehow it went out of sight for a while, and recently I picked it up again. Together with the templates from NetTiers http://www.nettiers.com/, CodeSmith can generate great deal of your code. These are the features delivered by CodeSmith/NetTiers:
- Generates ready to use Visual Studio projects and solution.
- Fully integrate with Entreprise Library application blocks architecture. Shipped with it's own plugin, so you can configure your application directly from the entlib configuration console.
- Generate business entities with a 1:1 mapping ( an entity for each table or view, with a property for each column).
- Serializable
- trigger events
- Implements an IEntity interface, which contains the columns that are present in every table
- Specific support for enums.
- Each object has a concrete and a base class which it inherit from. The concrete class is generated just once, so you have can use it to add you custom code.
- Generate Data Access Layer Components (DALC) for tables and views , with following database operations :
- upport for basic CRUD: UPDATE, DELETE, INSERT, SELECT ALL, PAGED SELECT, FIND
- Support for queries using primary key
- Support for queries using foreign key
- Support for queries using keys that are part of an index
- Support for queries using keys that are part of a junction table
- Support for user defined Methods, generated from queries that are detected throught a very simple naming rule (_TableName_MyMethodName)
- Support for Deep loading and saving, with children type selection and optional recursivity.
- Support for find methods, with paging and sorting. (builded with the datagrid in mind :-)
- NEW: Support for SqlView.
- NEW: Select between stored procedure or xml embedded queries.
- Generate strongly-typed collections for entities and repositories.
- Implement CollectionBase , IBindingList, IList and ICloneable
- Sortable, even Unsortable ;-)
- bindable to datagrid, or any winform or asp.net controls
- It creates ASP.NET webservice for distributed programming.
- Create the stored procedures script and can automatically install them on the server.
- Generates a complete nAnt build file, to compile, test and generate chm/html API documentation.
- A full set of nUnit tests.
- the code is fully nDoc commented (more, it use the Description extended properties of the data table and column) and follow the microsoft naming guidelines.
- Open source ! You can modify the templates and contribute
In my next articles I'll focus on how to automate the build and deployment process, using Visual Studio 2005, Nant/MSBuild, NUnit, FxCop, NDoc, CodeSmith and NetTiers Templates
- Erik
(*) Object Relational Mappers like http://www.hibernate.org/, objectspaces, www.allors.org, (comparison: http://www.theserverside.net/news/thread.tss?thread_id=29914)