Two Years Blogging

December 25th, 2005

On the 28th this blog turned two years old and I thought it would be interesting to post up a bit of a summary of the past two years on this blog. I thought it would be interesting to plot posts against comments.

BlogTrends

I’ve also decided that for the next month I will not post anything to my blog. I am taking a bit of a break because I have found it hard to keep up the same level of blogging that I had earlier this year. Hopefully I will come back refreshed and with lots of interesting things to say.

Thanks for listening and see you in January!

more…

Configuration Management

Using TFS shelvesets to check if you have introduced a new bug.

December 25th, 2005

Last night I was making a few code changes to an application to see what would be involved implementing a new feature. There weren’t that many changes but they were split across several layers of the application. To my dismay when I launched up the application the data field (silently) to read and write that data from the underlying storage system.

Because I had made a few changes it was possible that I had introduced the bug and I wanted to quickly check against the implementation that I got when I took the branch to implement the feature. Rather than manually putting aside the source files that I had modified (what were they again?) I decided to create a shelveset of my changes then undo my pending changes to take me back to the baseline.

I determined that there was an underlying bug in the code and that I hadn’t introduced the bug so I restored the shelveset and continued tinkering. The outcome isn’t that interesting, but I think the use of this unique TFS feature was a real time saver for me, and its not the first time that it has paid dividends.

more…

Configuration Management

Checking in with a child.

December 25th, 2005

I’m sitting at the gate lounge waiting for my flight. Bella (my daughter) isn’t here yet, her grand parents will get her here around 4 to 5pm.

When I arrived at the airport it dawned on me that I would need to check-in with Bella, otherwise they wouldn’t give us seats next to each other (not a problem for me, but the person sitting next to Bella might have an issue with it).

Based on previous experience I thought they were unlikely to give me her ticket without her standing next to me so I was potentially looking at a long wait on an uncomfortable seat – it was then that I devised a cunning plan.

The Virgin Blue Quick Check booths were standing there, and I had a soft copy of the itinerary so I positioned the bar code to the top of the screen and fed it into the scanner. Just like clock work it gave me the option to print Bella’s ticket as well.

At this point I’d like to thank the programmers of this terminal for not encoding all the business rules into the Quick Check system. Its comforting to know that someone could abduct my child and fly them interstate without anyone stopping to question them at the airport.

Anyway – back to cutting some code.

more…

Configuration Management

Hands-on Day: The Deed is Done

December 25th, 2005

I got on the plane this morning at 6:45am with my daughter to fly down to Melbourne to present at the Victoria .NET User Group’s Hands-on Day. Bella needed to come with me because Nicola had a prior engagement that she couldn’t cancel/re-arrange.

Obviously Bella couldn’t be at the hands-on day (she would steal the show) so her grand parents picked her up at the airport and dropped me off at the venue (thanks guys!). My bit started at about 10:40, and I went until about 11:30, then the attendees did a few hands-on labs and I wrapped up with a really quick look at some IDE enhancements.

I think it went down well, but I guess this stuff doesn’t really stick until you get to use it at work in anger.

more…

Configuration Management

The Importance of a Good Code Name

December 25th, 2005

Yesterday I attended a meeting with a member of a clients configuration management team. Eventually the topic of “what do you want to call your source repository” came up and we all looked at each other and blinked.

Eventually a neuron in my brain triggered and I realised that this was an opportunity to pick a code name! Several good options were put on the table but for some reason the development team leader baulked at them and opted for something mundane and boring ().

I can never understand why people choose grey names for projects, its their opportunity to put some of their personality into the project, but more importantly a good code name serves several useful purposes. A good code name:

  • is a short hand way to refering to the system.
  • is great for starting elevator pitches to executive management.
  • is a way of avoiding analysis paralysis on namespace naming.

If I have convinced you to create a code-name for your project, here are a few rules that I would stick to for .NET projects:

  • Avoid acronyms, they look like crap in namespaces.
  • Prefer a single word codename, two word tops.
  • Make it easy to search and replace in code.
  • Place names, people names and funny words make great code names.

Do you have a code name for your project? If not, make one up and just start refering to the project as that – see how quickly your co-workers catch on.

more…

Configuration Management

This is the life . . .

December 25th, 2005

I decided to catch a slightly earlier bus to work today so that I could catch up on a few podcasts. The first one that I had scheduled to listen to was the SQL Down Under podcast. This one is something special because it has Dr. Jim Gray who has had a hand in products such as DB2, Oracle RDB and of course several generations of SQL Server.

The hard questions about why SQL Server 2005 was so late were asked, but also questions about the future. I find the possibilities created by the CLR in SQL and LINQ coming down the line truely facinating. Is SQL going to become a data-aware application server? What happens as boxes scale up – is the midrange getting close to being able to clobber a mainframe without a cluster?

Greg also made a really great point about the reason for getting involved so early in product release cycle. Basically it boils down to being able to avoid having to keep on top of the evolving technology without having a massive learning curve every time a product ships.

Anyway – great show Greg!

more…

Configuration Management

Follow-up: Coding for Testability

December 25th, 2005

I got a few comments (3) when I posted up about coding for testability. Paul took the time to post a detailed comment which came out kind of mangled and then followed up on his blog. Paul extends the pattern, essentially adding a fair bit more code and structure – this is a good thing if you can keep it up, but I wonder if I did a spot inspection of Paul’s code whether he had used it uniformly ().

Actually - the main point that I wanted to make is what effect a simple change can have on testability. I also think that if you can be more surgical in which parts of the program you mock with test harnesses you can reach into different parts of the code. This helps you test specific things, but it also helps drive your code coverage up.

more…

Configuration Management

Heading down to Melbourne for the VDNUG Hands-on Day

December 25th, 2005

I’m heading down to Melbourne on Saturday to speak at the Victoria .NET User Group’s Hands-on Day being held at Cliftons. Bill McCarthy and Peter Stanski were originally slated to present but had to pull out. The title of the session is:

CLR, VB and C# IDE and Major Changes

I’m probably going to do more C# than VB but I will be sure to show how to use VB to exploit the latest changes in the CLR. I’m looking forward it, I haven’t been to a Melbourne event since the user groups officially merged under VDNUG.

more…

Configuration Management

BizTalk 2006: First Impressions

December 25th, 2005

Earlier this week I downloaded a CTP of BizTalk 2006, the first public build to be stabilised against the RTM version of the .NET 2.0 runtime. I’m doing a fair bit of work with BizTalk 2004 at the moment so I was interested to see what improvements they had made in the product.

This wasn’t my first attemped install of BizTalk, I had tried to do it three months ago when I got my hands on some very early bits – the installation hung on my machine, so hopefully this time around I would get further.

Installation

The real test for an installation of BizTalk is whether or not you can go through an installation and get it right without reading the absolute latest version of the deployment guide. I actually did quickly skim it just to see if anything jumped out at me – nothing did so I kicked off the installation.

The installation process has been revised a little bit and I liked the way that it went and downloaded the pre-requisites from Microsoft directly. That was always a pain previously – having said that, if you are installing BizTalk 2006 into a secure environment you are probably going to need to get the pre-reqs manually anyway since you will probably not be able to connect out to the Internet.

There were no complaints during the installation process but after it was all up and running I noticed that a number of SQL jobs were failing. The reason was that I installed using my domain user account onto my laptop which usually doesn’t have a connection to the domain controller – so SQL was essentially saying it couldn’t run the job because it couldn’t verify who I was.

It may be been in the deployment guide but I think next time I install I will use a local account to avoid that particular issue.

Administration Tools

One of the first things that I noticed was that the contents of the program menu for BizTalk had changed. Most notably, the Deployment Wizard wasn’t there.

BTS2006StartMenu

The configuration wizard had run automatically after the installation so all the databases were set-up, and it is worth noting that it has been given a bit of a face lift, unfortunately I think they took the bandages off too early and it has caused some scaring.

BTS2006Configuration

The tool itself is functional and gives you a lot of feedback about the health of the configuration and I am looking forward to having my first serious configuration issue and seeing how this tool helps me out. For now, I just want to point out a few UI-related things to the developers or PM behind this tool.

  • Don’t use a tree view as the navigation tool, it is so last century, do something like they do in the Windows XP Control Panel with the collapsable regions and hyper-linked navigation style. If you did that you could probably get rid of the menu strip and tool strip.
  • Don’t give the form a sunken edge.
  • Make the form resizable.

Before I move onto the new administration tool I need to point out that the Health and Activity Tracking tool hasn’t been given a face lift, although that didn’t worry me too much because all the functionality that I wanted from it has been moved into the administration tool – thats right the Administration Tool is now a read/write view over your BizTalk deployment! Lets have a look at the UI for the new administration tool.

BTS2006Administration

Man – thats slick! Lets have another look just for good measure!

BTS2006Administration

Ooooh! Gives me goosebumps! The tool is looking remarkably similar to the Enterprise Manager from SQL Server 2000. Under the covers it is actually using the new Microsoft Management Console 3.0 technology which introduces explicit support for managed code developers.

A few years ago I was asked to produce an MMC snap-in for the older MMC 2.0 technology and after about a week of trying to do everything that I wanted I decided to knaw off my arm and get out from underneath the mountain of COM interop code.

Hopefully developers who are producing server applications will use MMC 3.0 to provide administrative interfaces to their software – even for line of business applications. Having said that – the SQL 2005 team didn’t, but it probably wasn’t ready in time (they had already taken too many dependencies).

Anyway – back to BizTalk 2006! The first thing I noticed about the tool was that everything was much more configurable from the administrationt tool, pretty much everything you could do via the Visual Studio 2005 BizTalk Tool Window you could do here.

One thing I liked as the logical grouping of configuration settings into applications. You can create them directly in the console then load in your assemblies (under the resources section).

BTS2006Application

Once you load in your assemblies (it gives you the option to load them into the GAC) the Pipelines, Maps, Schemas and Orchestrations sections get filled out. You can then go in and configure the send and receive ports in the tool. I managed to deploy an orchestration via the administration tool in a few minutes without any trouble.

As you can probably surmise from the picture above I moved on to creating an “Enterprise Service Bus” application. I’ve since been advised that ESB is a Gartnerism, and as such I should refrain from using it – especially on this blog (given the name).

Development

So far the in Visual Studio 2005 experience is pretty similar to BizTalk 2004, but I really have tried doing anything fancy yet. Basically I built a quick pub/sub application which does translations to and from a canonical schema. The development phase went fine although there a few issues in deployment, one of them was a layer 8 problem (as Rocky would put it) which Bill was able to help me out with.

One thing that caused me some frustraition was that I was starting and stopping the logical application so it could start processing new messages/schemas that I had defined but it wouldn’t pick up the message type. Initially Bill thought it might be because the BizTalk deployment from Visual Studio did something extra to make BizTalk pick it up - but I have since discovered that I had to restart the host instance for it to be able to pick up the message type.

Once that was sorted it was smooth sailing – I kicked a few tires around inbound and outbound maps including flat file schemas and it all seems to be working OK.

There were a few things that I was disappointed about. One of my other passions at the moment is Team Foundation Server and I’ve been informed that the BizTalk project type won’t be supported by MSBuild natively which means we have to do some MSBuild hacks to get it to execute devenv.com. I hope they reconsider that feature exclusion because BizTalk definately plays in the enterprise space and I would expect it to work with Microsoft’s premier team development tools.

Summary

I think this version of BizTalk is going to be the first one to really get me excited. I always felt that BizTalk needed better administration tools and I think we get it in this version. The streamlined deployment and configuration process will make it appeal more to developers who are used to have good tools for other application infrastructure components like SQL Server.

more…

Configuration Management

Integrate Learning into Everything You Do

December 25th, 2005

You are a trader. You trade your time and skills for a monetary compensation. How much you get compensated is directly related to how much the person you are trading with values your skills. If you aren’t getting paid enough it is because you negotiated poorly or what you were selling wasn’t valuable enough.

Sometimes, as a trader, you manage to strike a bargain with your trade partner where they pay for you to acquire new skills. Don’t be fooled into thinking that this is for your benefit! Your savvy trade partner has realised that it would be cheaper in the long run for them to pay a bulk sum to get you trained up and continue to pay you the same ongoing amount than to have you go away and train yourself and come back demanding higher compensation forever and a day.

If you can manage to increase your compensation and have your trade partner pay for your skills improvement that is a truely sweet deal – a sign of good negotiation skills on your behalf!

Still – you will receive the greatest reward when you manage to acquire a new skill on your own because you can bring it to the trade table and sell it royalty free. In order to do this, and minimise your own costs you are going to need to learn how to integrate learning into everything that you do.

In the software development field there is a tendency to learn a new technology and stick to it until your skills reach obsolescence then start the cycle again. The result is a plateu effect.

StandardSkillsOverTime

Whilst it may appear the IT is continually evolving that is only because of the cumulative effect of everyones cycle overlapping. What you need to do is beat everyone else by bringing your skills to market before them, but in order to do that you need to minimise the amount of time you spend on the plateu.

LearningSkillsOverTime

How do you do it? Well I guess that is unique to everyone, but what I do is actively try to introduce new technologies into the projects that I am working on and try something different each time I do something that could be done the same way that I always did it.

Does this not introduce risk? Absolutely – but you don’t get rich in business without taking risks!

more…

Configuration Management

Coding for Testability

December 25th, 2005

There is no doubt that in recent years there has been an increased focus on unit testing our code before we throw it over the fence. Despite this increased focus we still see piles of code out in the field that is virtually untestable despite it exhibiting several other positive characteristics. So what is it that makes it so hard to write a piece of code that is easily unit testable?

Ironically I think that a lot of the blame falls on the unit testing gurus who produce frameworks which are supposed to guide us into making testable code. I’m talking about inversion of control frameworks which implement various flavors of the dependency injection pattern or the service locator pattern. While the frameworks themselves are powerful they are somewhat unapproachable to your average development team member which is having a hard enough time coming to terms with the humble DataSet – don’t laugh, every team has at least one!

Rather than focus on a set framework I think we should make one simple change to our collective coding styles. Lets take a look at the following piece of code that you might find any your typical layered business application:

public class CustomerBusinessComponent

{

    public Customer Find(string customerID)

    {

        CustomerDataComponent data = new CustomerDataComponent();

        Customer customer = data.Load(customerID);

        return customer;

    }

In this example we can see that the higher caller would invoke Find and this business component would then load the customer based on the customer ID that was passed in. Hopefully a business logic component would justify its existence by doing more than this, but it is fine for the purposes of this demonstration. The problem with this code is that it is tightly coupled with the layer below, which probably means it is tightly coupled (ultimately) to the database.

Microsoft product teams have a saying about not taking any dependencies when you ship, but we can understand where the SQL and .NET teams went so wrong – its so easy to do! We do it with every piece of code that we write! In order to make the code above more unit testable we should really extract the hard dependency on CustomerDataComponent so that we can provide our own implementation, here is a quick and dirty example that gets the job done.

public class CustomerBusinessComponent

{

    private CustomerDataComponent m_CustomerDataComponent = new CustomerDataComponent();

 

    public CustomerDataComponent DataComponent

    {

        get { return this.m_CustomerDataComponent; }

        set { this.m_CustomerDataComponent = value; }

    }

 

    public Customer Find(string customerID)

    {

        Customer customer = this.DataComponent.Load(customerID);

        return customer;

    }

}

The beauty here is that our test code can now provide its own data component implementation:

public class TestCustomerDataComponent : CustomerDataComponent

{

    public override Customer Load(string customerID);

    {

        Customer cust = new Customer();

        cust.ID = “DUMMY”;

        return cust

    }

}

 

[TestClass()]

public class CustomerBusinessComponentTests

{

    [TestMethod()]

    public void SunnyWeatherFindTest() // This is a Jackism.

    {

        CustomerBusinessComponent businessComponent = new CustomerBusinessComponent();

        businessComponent.DataComponent = new TestCustomerDataComponent();

        Customer customer = businessComponent.Find(”DUMMY”);

        Assertion.AreEqual<string>(”DUMMY”, customer.ID);

    }

}

There are a couple of subtle implications here. The first is that your should start defining the methods you are planning on stubbing out as virtual but you should also consider the other changes when you switch to this style of coding. First of all – lets say I instantiated my CustomerBusinessComponent, well my CustomerDataComponent would get instantiated automatically – but if I never called Find that could have potentially been wasteful. If you applied this pattern throughout your layers you could well end up with thousands of objects being instantiated just to make one simple call, so we can optimise the code to be more memory efficient (memory efficiency is more important than runtime efficiency in .NET – space is king).

public class CustomerBusinessComponent

{

    private CustomerDataComponent m_CustomerDataComponent;

 

    public CustomerDataComponent DataComponent

    {

        get

        {

            if (this.m_CustomerDataComponent == null)

            {

                this.m_CustomerDataComponent = new CustomerDataComponent();

            }

 

            return this.m_CustomerDataComponent;

        }

        set { this.m_CustomerDataComponent = value; }

    }

 

    public Customer Find(string customerID)

    {

        Customer customer = this.DataComponent.Load(customerID);

        return customer;

    }

}

Finally, there are a few things that you could do to improve this as a testing mechanism. First, you could make the test data access component take an anonymous method in its constructor which would allow the test case code to define what the return value from the dependency it is injecting. This could be useful when dealing with data driven unit tests in Visual Studio Team System or combinatorial tests in MbUnit – but that’s a topic for another technical moment!

more…

Configuration Management

Passwords: Reality check . . .

December 25th, 2005

So we all know the drill for passwords:

  • Make them unique, don’t use the same password twice.
  • Change them every month or so.
  • Make them complex, paraphrases are good.

I’m sorry, your reality cheque just bounced. Lets be conservative and say I have about twenty usernames and passwords for online sites including things like my blog, my personal e-mail, Passport and the like.

Because I am a consultant I also am actively managing between five to ten passwords to access client systems on top of my Readify username and password. I am forced to cycle each of these every one to two months and if I don’t lock out occurs. The cute thing about lock out is that it typically requires me to call an outsourced service provider over an unencrypted telephone network (no – I don’t have a speak easy sitting on my desk – and the help desk operator definately doesn’t).

So what is the solution? A password manager? Essentially a password manager hopes to defend multiple passwords through one super strong paraphrase-style password. That doesn’t make me terribly comfortable, but even if I could get over it I have a more serious problem to contend with.

For example – most password managers run on your local machine and require you to back up their data files (no problem). But what happens when I forget my laptop? Occasionally I go into high security sites where I can’t bring in my laptop or mobile phone - what do I do then? Should I load the data onto the Internet? Now I am feeling really uncomfortable!

The reality is that the security guys demand that we use complex and unique passwords but don’t consider how well that scales in reality. The only way a mortal can cope is by deliberately weakening their passwords so they can remember them.

What is the solution? Until strong biometrics are everywhere I don’t think there is one!

more…

Configuration Management

Be careful where you type in your Passport password . . .

December 25th, 2005

Rocky and Grant’s little story about the password generator over at Gibson Research reminded me of a little episode I had recently with one of the local .NET community members.

Basically this nice chap had decided to put together a little community site that allowed users to log in and share content, but rather than force them to remember yet another username and password combination they decided allow them to type in their Passport username and password.

Ummm – okay – pass. The key detail I have left out here is that the site is not a member of the Passport network, so they essentially take your username and password and store it in their database (whether it is hashed or not is irrelevant).

No – I am not going to link to the site.

more…

Configuration Management

Great little journaling tool.

December 25th, 2005

Grant points to a great little tool by Leon Bambrick and Atli Bjorgvin Oddsson. I was pondering today why timesheets are so hard – some people think that they are easy, but I don’t think they have to fill in the two different timesheets I have to, and I don’t think they are working across three projects simultaneously.

Anyway – its a neat find, now if only it could take a stab at filling in the timesheet for me automagically!

more…

Configuration Management

70-536: Collection interfaces

December 25th, 2005

The 70–536 skills matrix says that I need to know about the full set of collection interfaces inside the .NET Framework, specifically:

  • ICollection and IList
  • IComparer, IEqualityComparer and IKeyComparer
  • IDictionary and IDictionaryEnumerator
  • IEnumerable and IEnumerator
  • IHashCodeProvider

Rather than tackle these in order I will rearrange the list a little so it is a little bit more logical, first up the main interfaces!

IEnumerable, ICollection and IList

These three interfaces are the core of the collection system. IEnumerable defines one method called GetEnumerator which returns an object that implements IEnumerator. It is a generic mechanism where every object can work with the variety of “foreach” constructs in every language.

It supports forward only traversal over a set of objects – not only do you find it arrays and collection classes but you find it on other types such as System.String to allow you to enumerate over a block of text as a sequence of characters - very useful.

The ICollection interface actually inherits from the IEnumerable interface, so by definition everything an IEnumerable object can do an ICollection object can as well. What is different about the ICollection interface is that it represents a known quanitity of elements so that you can get a count of how many elements there are in the collection. It also introduces a number of properties to support synchronised access to elements (you lock on SyncRoot).

Introducing IList! I list inherits both ICollection and IEnumerable but adds a number of methods to support adding and removing items from the underlying collection of objects. In an amazing stroke of inconsistent naming you will find that most classes that implement IList are actually called somethingCollection, and not all those that have IList-like methods are actually IList implementors. The only reason I have to explain this inconsistency is history.

Many of the frameworks that Microsoft published in the past exposed collections of objects, and those collections were mutable with add and remove methods. I suspect that Microsoft could have called ControlCollection ControlList but the natives would have gotten restless.

IComparer, IEqualityComparer and IKeyComparer

These three interfaces are used in various ways by the collections framework in .NET. Take IComparer for example – it can be used to provide a sort ranking for any two objects. Now - there is a related interface called IComparable in which an element object can sort itself but it is fairly common for this interface not to be implemented so the IComparer gives you an external and more flexible mechanism for sorting.

One pattern that I used with comparers is to create one for each of my domain objects, then sub-class it for each of the various properties. These sub-classes then become accessible off the base domain object comparer as static properties (SortByLastName type stuff). If you want to get really fancy you can even make it support multi-property sorts by having the base comparer take a paramarray of sorts which it then applies sequentially to determine the ultimate sort order.

So thats IComparer – what about IEqualityComparer and IKeyComparer? Well IEqualityComparer is a special kind of comparer which is use to determine equality only – so it can’t really be used for sorts. Its reason for being is a bit fuzzy for me but from what I read the idea is that it is useful for culture aware comparisons where a straight string comparison wouldn’t work correctly. The MSDN documentation also had some interesting implementation notes:

“The Equals method is reflexive, symmetric, and transitive. That is, it returns true if used to compare an object with itself; true for two objects x and y if it is true for y and x; and true for two objects x and z if it is true for x and y and also true for y and z. Implementations are required to ensure that if the Equals method returns true for two objects x and y, then the value returned by the GetHashCode method for x must equal the value returned for y.”

Looks to me like a good candidate for a unit test whenever you implement one because it would be so easy to get one of those implementation details wrong and cause all kinds of wierdness.

IKeyComparer? OK – you could probably carbon date when this skills matrix was put together by the names of the interfaces and classes that no longer exist, but basically the IKeyComparer was slated to be renamed to IHashComparer. You can read about the change here on Krzysztof Cwalina’s blog – however, I suspect that this never happened and the interface has been dropped entirely.

IDictionary

The IList interface is all about storing a set of elements and making them indexable by a numerical key. The IDictionary interface expands the concept of having an index to access elements in a set by allowing you to define what that key value is. The IDictionary interface is kind of loose in that it allows us to use any key and any value as long as it derives from System.Object (now find me one that doesn’t). With the generic IDictionary<K,V> interface you can lock that down a little bit.

IEnumerator and IDictionaryEnumerator

Implementors of IEnumerator are returned from the GetEnumerator method from classes that implement IEnumerable. The interface defines two methods, Reset and MoveNext and a Current propertyly that allows you to grab the current element. The IDictionaryEnumerator is a specialisation of the IEnumerator interface for dictionary objects. It defines an additional three properties, Entry, Key and Value.

The Entry property is the same as Current on IEnumerator except it is hardwired to return a DictionaryEntry and the Key and Value properties just provide easier access to the the Key and Value properties of the DictionaryEntry instance returned by the Entry property (phew – what a mouthful).

Actually, one of the things that always gets me about working with dictionaries is that when I go to enumerate them in a “foreach” loop I get an InvalidCastException – its because I always think that I am just enumerating the values, not a set of DictionaryEntry instances.

IHashCodeProvider

The IHashCodeProvider interface has now been obsoleted and we should use IEqualityComparer instead (see above). I guess the theory behind this was that we shouldn’t allow people to get in and trash the hashing algorithm in classes like the Hashtable, instead we should give them a specific interface to implement for all the things that would normally make them take that drastic step.

 

 

 

more…

Configuration Management

Media Center, my new friend

December 25th, 2005

About 2 weeks ago i built my first Media Center PC.  I actually took an existing Media Center PC that I bought from a friend.  Well, I ended up stripping it down and using its component for my own PC.  Go ahead ask why….. the evil behind my madness was the media center I bought was a small form factor case, and the mother board on it, while good, wasn’t “Super Duper Great”.  So I built the PC, bought a new case, new motherboard, new CPU, and got everything up and running. Believe it or not, I think the hardest thing about building a Media Center PC, are getting the right tuner cards. Just make sure you buy tuner cards that are compatible with MCE, and the rest to me, was no more different then building any other PC.  Now I have to admit configuring the MCE software is not for the faint of heart, but I did manage to get it done.  I think the hardest thing to deal with was the screen resolution.  My challenge to the video card makers out there, and Microsoft is to make this easier.  Actually if Microsoft allowed you to resize the desktop, instead of using the full screen resolution that would have solved my problems in a heart beat. 

So its been about 2 weeks now and everything is great.  I can watch TV and play City Of Heroes at the same time. OK who am I kidding watching tv and writing my book.  Anyways, to get to the point.  I am doing this presentation this wednesday at CNUG (Chicago .Net Users Group) on Media Center Add-Ins, and I used the .Net 2.0 framework to do it.  Well, needless to say I ran into some problems while trying to run my code within the Media Center.  After a little investigation I found out that Media Center is a .Net application, so i wondered, what if I changed the supported runtime to .Net 2.0.  Well I tried it in a Virtual PC image, and it works flawlessly…. so far.  I even changed my home media center to the .Net 2.0 framework, and for kicks I deleted the .Net 1.1 framework, and everything has been ok for 3 days now. (crossing fingers). Now I can have my Add-In created in VS2005, and it works like a champ in my VPC MCE image, and on my Demo MCE machine.  And the icing on the cake is, that MCE seems to run smoother and faster now.  However, be forewarned, I doubt Microsoft will support the change to 2.0 framework

One thing I like to note, debugging a Add-In is a little tricky, you have to attach to the ehexthost.exe to debug your app, my suggestion is to use a dialog box.  Write your adding, in the first line of the Launch method throw up a medai center dialog box.  Once you fire up Media Center, attach to the ehexthost.exe, and set your break point if you haven’t already, then go ot the Media Center shell, and click ok on your dialog box.  Now you can step through your code.  I think you could also use the System.Diagnostics.Debugger.Break() method.  This way your code will stop, and you be asked which applciation you want to use to debug.  I have yet to try this, but I think it should work.

Also Exception handling and logging are very important, otherwise you will have no idea what’s going on within your .Net MCE Add-In, especially if something is exceptioning out.

more…

Configuration Management

OK I know its been a while

December 25th, 2005

Yes I know I am a bad blogger.  I am been crazy busy though.  The book, flight lessons, a third magazine article, trying to buy a house… phew its been crazy.  Last Saturday CNUG had their Day of .Net Conference which I was privileged to speak at.  Overall my topics went ok.  The first one bombed on me horribly, the second talk was ok, and the third went really really well.  I guess not all things can go perfect all the time.  Once the code and slide deck are posted I will post links on here.  So its been about two weeks and I have been playing around with .Net 2.0 and VS 2005, and I am a happy camper so far. more…

Configuration Management

Day Of .Net Code Samples… finally

December 25th, 2005

OK sorry for the delay.  I know many of you wewre looking for the code samples I used, but it has been a crazxy month for myself, and the CNUG site administrators.  Good news is they are finally up there so here are the links.

Code Dom Presentation

WSE 2.0 Presentation

Make sure you are using the 1.1 Framework and WSE 2.0 SP3

more…

Configuration Management

Day Of .Net

December 25th, 2005

Well last Saturday April 30th the Chicago .Net Users Group (CNUG) had their 6th Day Of .Net.  If you have ever heard of Code Camp it is a lot like it.  I spoke on two sessions.  the First was on Code Generation witha  focus on the CodeDom, and the second was on WSE (Web Services Enhancements).  Both went off without a hitch, my demos worked so that was a plus. 

There was an interesting discussion during the WSE session about interoperability between a java web service and a .net application.  The same could be said of the reverse as well.  In Java, for example, the DateTime data type supports null values, however in .Net it does not.  Hence, a .Net application trying to consume a Java web service with a null value for a DateTime, blows up remarkably well.  The same is probably true when trying to consume a .Net web service passing a dataset to a Java application, but I could be wrong maybe someoen has created the ability for a Java web service proxy to create a .Net like dataaset.

The moral of the story is, be careful while creating web services especially if you want them to be consumed by hetereogenous systems. Creating a web service does not promise compatibility with anything that can consume.  Maybe one day someone will generate a wsdl generator that can output to multiple langauges (Java, C#, VB.Net, etc…), and be to handle datatypes from hetereogenous platforms.  That would be cool.

 

more…

Configuration Management

My Configuration Management Application Block article for CoDe Magazine

December 25th, 2005

Here is my CMAB How-To article http://www.code-magazine.com/Article.aspx?quickid=0505061.  This article goes into the inner workings of the Configuration Management Application Block, and demonstrates how to use it. 

Rocky Lhotka also wrote an article on the CMAB for CoDe Magazine this month. http://www.code-magazine.com/article.aspx?quickid=0505071 His article goes into using the CMAB for Enterprise, User, and Client settings data. 

Note don’t confuse this CMAB with the Enterprise Library Configuration Application Block.  The CMAB is the predecessor to this.

more…

Configuration Management

News on me - Speaking in Raleigh, and Book

December 25th, 2005

Well just for all hose that follow my blog.  I figure I fill ya in whats new first I spoke at the MSDN Code Camp in Raleigh, North Carolina.  I have to say I had a blast.  My presentation as on Unit Testing using the tools of today and tomorrow.  I plan on posting the slide deck on here sometime this week. I’d like to thank Rob, and the local Raleigh .Net user groups for having me.  It was really a wonderful time, the attendees where great, the fellow speakers (Jim Duffy, Doug Turnure, Maxim V. Karpov, John Shipway, and many more), and hosts were amazing.  I would speak at one of these again in a heart beat

Well I am going to make it official.  I have started working on a book on the Microsoft Enterprise Library Application Blocks.  I was originally going to try to write a series of articles on them, but I would never do them justice.  The guys in PAG did an amazing job on the 1.0 release, and there will be probably a port over to the .Net 2.0 framework.  Time will tell.  Anyways expect my book to be out around the very beginning of 2006 (Janurary).  I know this is going to be a rewarding and painful experience at the same time.  I am used to it if I could survive 8 weeks of basic training in the military this should be a cake walk :)

more…

Configuration Management

TechEd here I come

December 25th, 2005

Well it is official.  I am going to Tech Ed in Orlando this year.  I expect there to be a lot of exciting stuff there especially on .Net 2.0 and VS 2005.  I have a time share in Orlando so i plan on staying there.  So for all those that want to get together, and meet up.  just get a hold of me.  One of the most important things I do at TechEd is networking.  We are all in the same boat so we must paddle together.  I wonder if they will have another gaming area like they did last time. more…

Configuration Management

VSTS Pricing

December 25th, 2005

Well I am assuming Microsoft assumes that everyone has deep pocket books, because your going to need them for Team System.  I was a big supporter / advocate of the idea of Team System, the problem is after the betas go out.  I can’t afford to support it or advocate for it. It is way beyond my pocket book.  I can buy a new car for what it would cost me.  I suggest Microsoft come up with some way to allow the consulting world to learn these tools economically. I realize and fully support the price when it comes to implementation.

 

I suppose for now I will be using my trusty NUnit, and NAnt tools for a long time to come.

more…

Configuration Management

Not a good day

December 25th, 2005

Well this morning I woke up, and I noticed an ever increasing pain in my lower left back.  Right away i said to myself “oh no not again”.  I went to the bathroom, and sure enough I found another symptom of something I have dreaded and lived with 9 times already.  I figured while  was still coherent I would drive myself to the hospital. 

I got to the ER, checked in, and immediately the staff started pushing drugs, and IV fluids.  At this point I would have to say my pain was the worst I have ever experienced yet. The pain was shooting everywhere.  The pain was worse then getting kicked in the family jewels a thousand times over.  I would have welcomed that over what i was going through.  Then the fun narcotics kicked in and the pain started to go away.  I had a CAT scan done, and the doctor came into my room.  She confirmed my fears.  i was passing another kidney stone, and it was still there.  on top of it she said both kidneys had more stones waiting to be released.

It’s back to the urologist for me.  I am too young for this, my diet is not the greatest but it is not the worst.  So for the next few days, I am taking it easy.

Not a good day.

more…

Configuration Management

VB6, Relationships, and Marriage

December 25th, 2005

You know I have had an entire weekend not to think about this.  I DJed at my local residency, saw my daughter, man is she getting older, and visited family and friends. 
 
Now that my mind is cleared I would like to continue more on this VB6 “life support“ topic.  Granted I personally would love to pull the plug, and give it a final resting place  However I will admit I have had a relationship with VB6 in the past.  It was a powerful relationship that we had shared.  But as with most of my relationships in the past, I was yearning for something more.  I was a VB Win Forms, ASP COM+ guy not too many years back, but I have sense divorced VB6 due to unreconciled differences.  VB6 and I agreed this would be the best thing for both of us. The divorce was pretty clean cut and dry, no fuss, no muss, it was very quick.  Now I only see VB6 when I need on of the COM components we made together.  .Net does not mind too much, but I know it rather have had these component created with .Net and I. <sigh>  I don’t look back now that I have moved on - I don’t look back.
 
On a more serious note, I was reading a few blogs on this and I found some interesting posts.  One suggested making the VB6 runtime open source.  OK I can handle that, while they are at it maybe they could make FoxPro open source too.  I am sure one or two developers out there would love that.  This way the people that want to live in their VB6 world can.
more…

Configuration Management

VB6 what? Are you kidding me?

December 25th, 2005

Others are being “PC” about this subject.  For those who know me personally that at times is hard.  So for now I won’t even try to be “PC”.  If this offends you in anyway, well too bad.

What really depresses me is how developers who should be on the fore front on embracing change can be the most stubborn people on the planet.

News flash.  Technology will change!  Why you ask?  Simple we need to “do more with less“ (Ummm that sounds familar some how).  We need to do it faster, better, smarter, cheaper.  This is why we upgrade hardware, why we are constantly evolving the way we develop in hopes of being able to do create better software then before (OOA, COA, SOA, etc…).  So this need to constantly improve is going to force us to evolve.  This is why we do this.- This is why we have to do this.  Even .Net we will turn into something new and different.  One day C++ as we know it today will be no more.  It is in our own best interests to push ourselves to new horizons

For those of you that believe that Microsoft should continue supporting VB6, here is my comment

echmmm .  Cry me a river, build a bridge, and get over it.

Now I will admit that MS missed the boat when it came to the VB to VB.Net upgrade wizard.  however , instead of putting all this effort to try to stop change why don’t you put effort into making the evolution smoother.  Why doesn’t anyone try to improve the VB6 to VB.Net wizard or make there own.  Create a workspace on GotDotNet and create a solution. 

Don’t be part of the problem be part of the solution.

Thank You

 

more…

Configuration Management

Service Orientation - Today and Tomorrow

December 25th, 2005

I just happen to read an interesting article on the Server Side .Net titled “The Intersection of Objects and Services” (http://www.theserverside.net/articles/showarticle.tss?id=IntersectionsObjectsandServices), it was written by Rocky Lhotka.  I found it to be very interesting, a lot of good points were made.  The part I found most of interest was the “Service Thinking” section.  It is sad to say, I agree with Rocky’s conclusion that people think web services mean SOA, and SOA means web services.  I suppose you could blame marketing hype for that.  I think developers out there should know that SOA should have nothing to do with web services.  Web Services should just be a transport mechanism.  Heck I could use DCOM, or Remoting, even SMTP to create a service orientated application.  SOA also does not necessarily mean SOAP either.  Really I think today’s version of Service Orientated Architecture is just an evolution of Component Orientated Architectures.  Some may try to argue the same.  And after reading Rocky’s article on what he thinks SO should be as oppose to what the world thinks it is.  well it seems pretty exciting and cool to me, in fact I think it makes complete sense.
 
So I suppose the first question to ask is.  Is there a difference between Component Orientation, and Service Orientation?  I think so, Component Orientation allows an object to be passed around. This object would contain both the data, and possibly some implementation.  An example of this would have been retrieving a recordset from a middle tier server via DCOM.  You remember recordsets right, VB6, etc… :)   Service Orientation on the other hand is data centric, so all that is passed around is just the data / message - No implementation here.  Now CO and SO are similar in that for the most part they provide an API like interface that is typically stateless, well at least in the purists mind it would be stateless.  So why use SO, well the answer in my mind is simple.  Since SO deals with the data as opposed to the implementation.  It will be much easier to support cross-platform functionality, and I don’t mean just between a java application and a windows application.  It can also potentially support calls between different versions or evolutions of an application.  Could you get a VB 3.0 Windows application to talk to a managed .Net component directly today?  Now how about if you used a common transport mechanism (HTTP), as well as a common message format (SOAP).  Ok yes I do realize that you would have to build your own XML parser, etc.. in VB 3.0.  But I think you get the point of where I am trying to go.  Imagine for once you truely don’t have to “Fix something that is not broken” just because you want to evolve your infrastructure.  
 
Now abstracting the data from any implementation code is the first step in a true SOA environment.  The next step, I think is going to take a revolutionary mind set change.  As Rocky mentioned in his article, and as I also believe, SO should be more like messaging endpoints.  Essentially you can pass any kind of message to a service, and it will determine what the proper action is based on the message. Once it determines what it can or can not do, and performs any “black box” actions.  It will then return a message back to the caller.  I feel even for myself this would be a shift in how I think about software development.  Again this message endpoint concept should have nothing to do with web services, and it could be easily done with MSMQ, remoting, etc…
 
Well I suppose only time will tell on how SOA will evolve, but I can guarantee you this.  The future will be an interesting ride, and the way we do things today will one day be called “Old School thinking”.
more…

Configuration Management

More on my SOA Framework Idea

December 25th, 2005

Well I have been giving this some more thought and I have some ideas on what this will be.
 
First lets look an awesome definition of SOA from CBDI.
“The policies, practices, frameworks that enable application functionality to be provided and consumed as sets of services published at a granularity relevant to the service consumer. Services can be invoked, published and discovered, and are abstracted away from the implementation using a single, standards-based form of interface“
 
I like this definition because I think it is more realistic then saying a SOA has to contain “black box” services on some application server.  I firmly believe that any application should “crawl, walk, and then run”.  Don’t try building more then what you need keep it as simple as possible. 
 
So my SOA framework will require n-layer development, but n-tier development will be optional, but yet supported.  In order for it to support being “abstracted away from the implementation using a single, standards-based form of interface“, it will rely heavily on the use of interfaces between the layers.  I also plan on leveraging Microsoft’s Enterprise Library for exception handling, data access, and configuration management.  The user interface components will support a Model-View-Controller design pattern thus making it easy to support different types of smart clients with very little re-work.  I also plan on using Factory design patterns where ever it makes sense, such as in the UI to call up a Service Facade.  The framework will be such that communitcating betwwen tiers will support just about any message transport you can think of.  (In-Proc, Web Service, Remoting, etc…)  I feel very strongly that SOA does not mean Web Services.  Web Services is simply a message transport vehicle - Get my message from point A to point B.  SOA is bigger then Web Services, and I this SOA framework to honor that. 
 
So my next steps are to create a hig level component view of all the pieces..  i ahve mentioned some but obviously there should be more.  The framework will consist really of two sub pieces; The Provider and The Consumer.
 
As always chime in with your thoughts.
.
more…

Configuration Management

What the world needs now is SOA sweet SOA

December 25th, 2005

I am sure everyone out there has heard of the buzz words surrounding Service Orientated Architectures or SOA for short.  And I am not about to go into there design/ philosphy or compare them to Object Orientated Architectures.  What I feel si missing is a good SOA framework.  Something that everyone can use to help build a consistant clean application.  It would have to be transport independent, and of course loose coupling would be key.  I actually in my mind picture two frameworks that can work together a SOA Consumer Framework, and a SOA Service Framework.  They could b used together or independently, and I would not be looking to re-event the wheel, just tweak some existing framework concepts to support SOA better. 

These are just random brain storming thoughts maybe i will get around to doing something with them one day.

more…

Configuration Management

Windows CE 4.x Emulator / Virtual PC issue - DEP, PAE

December 25th, 2005

Well for Christmas like every year I decide to get one thing for myself.  For 2004,  I decided to build a new PC for me. :) .  Well of course I bought the best of the best PCI-Express Mother board a 6800 Nvidia card, etc…. And I did not spend a lot either which I was relatively pleased with.  I put everything together and whiz bang, this machine cooks.  In fact, I had absolutely no issues, put everything together including the fun neon lights, and liquid cooling system. And it fired up perfectly the first time.  Installed the OS and I was a happy PC User.  Of course the first things I did was install my whiz bangs and played them. 

 

Well it has been about a month and half, and i figured it is time to install Visual Studio .Net 2003, Virtual Server 2005, Sql Server 2000, etc.. -  all the fun things you will need to develop with.  Well this weekend I decided to start working on a simple inventory system for a friend of mine.  She sells Mary Kay Products, and well i thought it would be cool.  To create a Win App, and Smart Client app for the Pocket PC.  So I go ahead and fire up VS 2003, create a new Smart client device, select Pocket PC 2003 as my target device, I decide to run the debugger, and BOOOM.  It dies saying, It was unable to run the emulator.  So I re-install the Pocket PC 2003 SDK nope still doesn’t work.  I reboot my machine.  STILL doesn’t work, and now I get an error message at start up saying the Windows CE emulator, and Virtual PC device drivers  are prevented from starting due to instability issues.  After about 5 minutes of cursing to myself.  I decide to Google the problem, and I found others that have had similar problems.  The Microsoft recommendation was to remove the /PAE switch out of the boot.ini file.  PAE stands for Physical Address Extension which allows for greater then 4 GB of memory to be addressed.  Guess what I found in the Boot.ini file, thats right not the /PAE switch, so I find googled again, and found other users with the exact same issue, and they could not find the /PAE switch either.  Well i went pack tot he Microsoft documentation and I notices the date was back in 2002.  Mmmm this is Pre Service Pack 2, so i did some more hunting and sure enough I found that the PAE switch is assumed to be turned on when DEP is enabled.  Check out this Microsoft link for more details.  http://www.microsoft.com/technet/prodtechnol/winxppro/maintain/sp2mempr.mspx.  The solution is to put in a /NOPAE in the boot.ini file, again it is explained in the link just mentioned.

So if you got issues try this out.  I hope I can save someone else the headaches.

more…

Configuration Management

Composite UI Application Block - Community Technical Preview

December 25th, 2005

The Composite UI Application Block is designed to help you build these complex, enterprise ready Windows Forms—based solutions. It provides a proven architecture and implementation that helps you to build applications using the common patterns found in line-of-business front end applications.

Benefits

Building an application using the Composite UI Application Block provides the following benefits:

  • Increased solution quality and consistency for architecture teams by providing a structured, prescriptive environment that fosters reusability and predictability to build user interfaces.
  • Increased productivity and faster ramp-up time for large development teams, by hiding complexity and allowing them to focus on the business related components instead of on the underlying infrastructure and complex aspects of user interface development, such as threading and asynchronous processing.
  • Consolidation of operational efforts for operations teams by standardizing services that result in consistent configuration management and instrumentation implementations across a suite of applications.

This Community Technical Preview of the Composite UI Application Block can be downloaded from the Community Site. Important updates to this component until its final release will be made available on this site.

 

more…

Configuration Management

Enterprise Library June 2005 now available!

December 25th, 2005

Enterprise Library June 2005 now available!

The June 2005 release is a minor update to the original January release. It incorporates the patches and extensions previously released to the community, and also includes miscellaneous minor bug fixes. Although this release is still designed for .NET Framework 1.1, it is now possible to use this with .NET Framework 2.0 beta 2 - see the included Readme file for details.

 

 

more…

Configuration Management

Register HotKey fix

December 25th, 2005

I wrote a HotKey component a few month ago and some reported me a bug that suspend, shutdown or restart did not work while the Hotkey was in use.

This bug was fixed and I updated the code on the original post: http://dotnetjunkies.com/WebLog/principal/archive/2005/04/21/69872.aspx

I was trying to find a way to register a hotkey without the use of the form’s handle and the code that was on that post was one of those tries…

more…

Configuration Management

Data Mapping Application Block

December 25th, 2005

“The Data Mapper is a layer of software that separates the in-memory objects from the database. Its responsibility is to transfer data between the two ends to isolate them from each other. With Data Mapper the in-memory objects needn’t know even that there’s a database present; they need no SQL interface code, and certainly no knowledge of the database schema.” (Fowler, Martin, Patterns of Enterprise Application Architecture, p. 165) Data Mappers equate to what is known as Data Access Logic Components (DALCs). This application block is intended to make it easier for producers of business DALCs to create common functionality that relates to managing “entities” with CRUD functions. The DataMapper also promotes the use of stored procedures as a best practice to abstract data access from the underlying data schema and increase performance. Finally, the DataMapper allows capabilities like the use of transactions, command timeouts, and caching properties to be added, removed, and modified through configuration when needed. For example, to add transactions or caching to a DALC, no code will need to be modified — only configuration settings.”

Find out more here

more…

Configuration Management

Looking for a new host…

December 25th, 2005

For the last couple of weeks I recieved a huge amount of spam from this blog.

I am now looking for a new (better and spam proof) place to host my blog.

If you are familier with a decent host please contact me.

Ido

more…

Configuration Management

MSN Messenger personal messages

December 25th, 2005

Since MSN Messenger 7.0 released many people started to use the personal message to put a state about their feelings, life and “hints” they want to give to a specific person on their contact list.

I think the “personal” message is a very good way for a non formal communication. If you are a sensitive person with emotional intelegent abilities I am sure you know what I mean…

Here are some of the personal messages I have on my list…

  • “There ain’t no such thing as free lunch.” - R. A. Henlein
  • I love deadlines, I like the whooshing sound they make as they fly by.
  • Professionals built the Titanic, amateurs built the Ark of Noah.
  • Ignorance is bliss.
  • Still haven’t seen Ep3…
  • Mortgage is all you <don’t> need
  • Don’t kill the messenger!

as for my own:

“It is wonderful to be in on the creation of something, see it used, and then walk away and smile at it.” – Lady Bird Johnson

 

Life could be so beautiful if you just stop for a look :-)

more…

Configuration Management

RegisterHotKey Implementation

December 25th, 2005

Dan Amiga who is a great co-worker and a very tallent person showed me a very cool shortcuts application (C++) he wrote. I was so amazed about how easy it is to access any applications with few key strokes that I went home and wrote my own implementation for the same applciation, in C# of course.

The #1 thing I did was to implement this Component which fires a HotKeyPressed event when a desired windows HotKey was pressed.

Here is the implementation :

UPDATE: There was a mistake with the intptr Handle. Notice that now you need to supply the Form.Handle to this component. Suspend, Shutdown and Restart will work properly now…

public

class HotKey : Component , IMessageFilter

   {

      public event EventHandler HotKeyPressed;

      private const int id = 100;

      #region

Native win32 API

      private const int WM_HOTKEY = 0×0312;

      [

DllImport(“user32.dll”, SetLastError = true)]

      private static extern bool RegisterHotKey(IntPtr hWnd, int id, KeyModifiers fsModifiers, Keys vk);

      [

DllImport(“user32.dll”, SetLastError = true)]

      private static extern bool UnregisterHotKey(IntPtr hWnd, int id);

      [

Flags()]

      public enum KeyModifiers

      {

         None = 0,

         Alt = 1,

         Control = 2,

         Shift = 4,

         Windows = 8

      }

      #endregion

      public event EventHandler KeyChanged;

      public event EventHandler KeyModifierChanged;

      private IntPtr handle;

      public IntPtr Handle

      {

         get { return handle; }

         set { handle = value; }

      }

      private Keys key;

      private KeyModifiers keyModifier;

      private bool isKeyRegisterd;

      public HotKey()

      {

         Application.AddMessageFilter(

this);

      }

      ~HotKey()

      {

         Application.RemoveMessageFilter(

this);

         UnregisterHotKey(handle, id);

      }

      private void RegisterHotKey()

      {

         if (key == Keys.None)

            return;

         if (isKeyRegisterd)

            isKeyRegisterd = !(UnregisterHotKey(handle, id));

         isKeyRegisterd = RegisterHotKey(handle, id, keyModifier, key);

         if (!isKeyRegisterd)

            throw new ApplicationException(“Hotkey allready in use”);

      }

      [Bindable(

true), Category(“HotKey”)]

      public Keys Key

      {

         get { return key; }

         set

         {

            if (key != value)

            {

               key =

value;

               OnKeyChanged(

new EventArgs());

            }

         }

      }

      [Bindable(

true), Category(“HotKey”)]

      public KeyModifiers KeyModifier

      {

         get { return keyModifier; }

         set

         {

            if (keyModifier != value)

            {

               keyModifier =

value;

               OnKeyModifierChanged(

new EventArgs());

            }

         }

      }

      public bool PreFilterMessage(ref Message m)

      {

         switch (m.Msg)

         {

            case WM_HOTKEY:

               OnHotKeyPressed(

new EventArgs());

               return true;

         }

         return false;

      }

      private void OnHotKeyPressed(EventArgs e)

      {

         if (HotKeyPressed != null)

         HotKeyPressed(

this, e);

      }

      private void OnKeyChanged(EventArgs e)

      {

         RegisterHotKey();

         if (KeyChanged != null)

            KeyChanged(

this, e);

      }

      private void OnKeyModifierChanged(EventArgs e)

      {

         RegisterHotKey();

         if (KeyModifierChanged != null)

            KeyModifierChanged(

this, e);

      }

}

more…

Configuration Management

FXcop chat on Microsoft Chat Room

December 25th, 2005

Just now the FXcop chat was ended on Microsoft Chat Room.

I asked several questions that was troubling my mind. Here is a cool answer that made me think of a cool application to write…

MikeFan [MS] (Expert):
Q: Will FxCop work with reflection which means that I will have to build the assembly before I get the information about what rules I broken?

A: FxCop is a binary analyzer. So, yes, you must build your assemblies before we can analyze them. FxCop does not use reflection for this work, we have our own, entirely passive metadata reader that cracks binaries and extracts IL for analysis. This metadata reader allows us to avoid loading your assembly into the runtime, which provides several advantages (such as the ability to recompile your dlls with FxCop up and analyzing them).

MikeFan [MS] (Expert):
Q: Wow! MikeFan, will you release a code sample on how to access the assembly metaData without the need to use reflection?

A: We will not be distributing metadata reader samples, no. The reason for this is that our metadata reader is not itself a redistributable library. There is an initiative internally to provide external customers an alternate metadata reader. The group is code-named Phoenix, if you’re interested in non-reflection-based assembly browsing, you might try to get more info on them (search the web). Also, Lutz Roeder (author of Reflector and also an MS employee) has developed his own metadata reader that is available for download by visiting his web site. Search on his name or ‘reflector’ to find a link.

more…

Configuration Management

What’s wrong with the .net framework design today?

December 25th, 2005

When I think of design, I think of simplicity. If it’s easy to use the API then the design is good. However, if using the API result with repeatedly scenario in which a common code is written. This should return you to redesign the entire API.

For example the Cryptography in the .NET framework. Cryptography means either to Encrypt/Decrypt or to Hash/ValidateHash. It should not be more complicated then that.  EntLib cryptography’s API is a much better one. Moreover, to make use the .net framework cryptography in different project you always have to write some more code. Which again return to my point…a design Err.

To better demonstrate what I mean, here is a small example about Binding

Binding binding = MyControl.DataBindings[“Text”];

This is what the .net framework gives us as developer. In almost every Binding scenario I worked with, this was not enough. Projects I worked on usually need to do the binding again when the datasource changes. This result in a common code like :

Binding binding = control.DataBindings[controlProperty];

if (binding != null)

control.DataBindings.Remove(binding);

Which means we can simply add a helper class that encapsulate this code to a better API.

public

sealed class DataBinding

{

public static void Bind( Control control,string controlProperty,object dataSource,string sourceProperty)

{

Bind(control,controlProperty,dataSource,sourceProperty,null,null);

}

private static Binding ReBind(Control control,string controlProperty,object dataSource,string sourceProperty)

{

Binding binding = control.DataBindings[controlProperty];

if (binding != null)

control.DataBindings.Remove(binding);

binding = new Binding(controlProperty,dataSource,sourceProperty);

return binding;

}

public static void Bind(Control control, string