Oct 162012
 

UPDATE: due to many requests, I have compiled the code below into a project that you can download from here: Validation.zip

To my big surprise the Microsoft team behind the WinRT XAML framework has decided not to include the built-in support for validation that exists in the WPF and Silverlight frameworks. Anyway, for anyone that needs an alternative, I have created a set of helper classes to make things easier.

Shout it

Continue reading »

Sep 222012
 

With the changes to the UAC system in Windows 8, it seems that whenever you try to launch an non-elevated application from an elevated application, you get an error similar to: “Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)”.

The reason is that under Windows 8, even if you set UAC to the lowest setting, you don’t disable it completely.

In my case, I was trying to start an URL using the default browser from an elevated application. After a lot of digging around on stackoverflow.com and other blogs and websites, I’ve managed to build a solution that seems to be working.

Continue reading »

Jun 082012
 

We would probably have these horror masterpieces:

  • “Dead code don’t talk”
  • “Threaddy vs JSON”
  • “The Garbage Collector”
  • “Internals”
  • “The silence of the lambdas”
  • “I know what you did last method”
  • “I still know what you did last method”

or these adult movies:

  • “Show me your privates”
  • “Inside her sexy braces”
  • “Deep nesting”
  • “Show me your var Gina”
  • “Class action”
  • “Finalizers”

or Sci-Fi stuff like:

  • “Matrix trilogy” : “The Rotation Matrix”, “The Translation Matix”, “The Scaling Matrix”

or action movies like:

  • “Frozen”
  • “Try hard”
  • “Catch”

The best thing is that all of these are girl movies. They all cry at the end when this hero is Disposed.

Hopefully this makes you end the long workday with a smile. Happy weekend!

Apr 092012
 

In Visual Studio 2010, depending on the project type you get different options when you want to add new items to a project. If you have created a class library and later you figure out that you want to add WPF custom controls, you will need to change the project so that it supports this functionality.

Continue reading »

Aug 242011
 

There are situations in which you need to do some processing when an event fires but you don’t want to do it every time if the event happens in a very short time interval. Such a situation can occur for example when handling MouseMove events – you want to do the processing when the mouse stops for a certain amount of time, but not for every intermediate position of the mouse.

Shout it

Continue reading »

Feb 122011
 

 

In this blog post I am presenting a simple validation framework that you can reuse in your code. Also I will be putting here two code snippets that will make it easier for you to add preconditions to your code.

When Visual Studio 2010 was first realeased, one of the features that I expected the most was code contracts. Unfortunately after including them in one of my large projects, it became more clear that at this moment it is not mature enough to be used. Build time increases rapidly when having a lot of source code files and using the code contracts. Enabling static contract validation is even worse, almost doubling the build time on an average development machine.

All that being said, I really like the code contracts way of specifying preconditions. Most of the time I don’t use post-conditions, but being able to specify validation criteria means that the code will be more robust.

Continue reading »

May 102010
 

In the first part I’ve written about creating a code generator in VS2008 to eliminate repetitive coding.

The series is divided into four parts:

Part I  – creating a Visual Studio Package

Part II (this one) – creating and registering a code generator

Part III – generating code & debugging

Part IV – creating the setup project and deploying the package

So let’s jump directly to the problem at hand:

Continue reading »

May 072010
 

I am a big fan of the DRY principle. This means that whenever I can do something that can be reused with minimal or no effort, I try to do it. Recently I’ve started developing a REST framework for our projects, which is not based on WCF (will blog about this too). One of the most problematic areas is how to create service proxies easily without having to duplicate loads of code, but at the same time maintain maximum flexibility. After going through several options, the most attractive is creating a Visual Studio custom code generator.

Since there are almost no resources (and the existing ones are very blurry) I’ve decided to create a series of blogs that will be a guide to creating custom code generators, followed by some other posts with real examples and solutions to problems.

The series is divided into four parts:

Part I (this one) – creating a Visual Studio Package

Part II – creating and registering a code generator

Part III – generating code & debugging

Part IV – creating the setup project and deploying the package

*DISCLAIMER* – Even if everybody is in the new VS2010 hype, I still think there are a lot of developers that are and will be working in VS2008 for a while.

Continue reading »