Archive For The “.NET” Category

IIS vs a Windows Service: some important considerations

Can’t decide whether to host your WCF service in IIS or a Windows Service? Consider the additional steps you’ll need to perform, explain, troubleshoot, and write documentation for if you follow the IIS route: Ensure IIS is installed. Run aspnet_regiis -i to install .NET ISAPI module. Run ServiceModelReg –i to install handlers for *.svc file [...]

Read more »

One NHibernate session per WCF operation, the easy way

This week I’ve been working on a brownfield Castle-powered WCF service that was creating a separate NHibernate session on every call to a repository object. Abusing NHibernate like this was playing all sorts of hell for our app (e.g. TransientObjectExceptions), and prevented us from using transactions that matched with a logical unit of work, so [...]

Read more »

Merge redundant assemblies

Lately I have become a big opponent of a popular anti-pattern: people insisting on splitting up their application tiers/layers into 5-10 separate Visual Studio projects and adding references between them. Double that number of projects if you want corresponding unit test project for each layer. In fact, removing them has become one of the first [...]

Read more »

Powershell to recursively strip C# regions from files

Here’s a super quick little powershell snippet to strip regions out of all C# files in a directory tree. Useful for legacy code where people hide long blocks in regions rather than encapsulate it into smaller methods/objects. Run this in your solution folder and support the movement against C# regions!

Read more »

Exception handling no-no’s

Just spotted this in a project I’m working on: Writing code like this should be a shooting offense. But wait, there’s more! Check out its usage: Agh! Code like this demonstrates a complete misunderstanding of CLR exception basics — inner exceptions and formatting — and also log4net. All that hand-rolled formatting could simply be replaced [...]

Read more »