Tuesday, February 02, 2010
More Fun with Fluent NHibernate Automapping
Creating a Simple IoC Container
Read more: Tim Ross
Phalanger
Read more: Phalanger
.Net Remoting Made Easy
Global Windows Hooks
There are many articles of this type, but I didn't find any article discussing about how to hook the mouse and the keyboard using Visual Basic .NET. Since I have done this in VB.NET, I decided to post it here for people who will need it.
This project is a single component that contains various Windows hooks (I might add some other hook types in this component in future, if I have time).
- Clipboard hook
- Keyboard hook
- Mouse hook
It is a library file WindowsHookLib.dll that can be referenced from various projects.
This component differs from what I have seen in other similar articles, by providing two more things:
- Preventing a message to be passed to other windows.
- Raising the
MouseClick
andMouseDoubleClick
events. (I have never seen them in other low level hooks!)
Read more: CodeProject
The Pain of deploying Primary Interop Assemblies
Alright, first of all, what are Primary Interop Assemblies (PIAs), and why am I devoting an entire post to the pains caused by deploying these things? And secondly, how do they relate with what we’ve been talking about thus far?
The answer to the second question is simple – we’ve been talking about COM Interop in C# lately, and we’ve just gotten through how C# 4.0 makes Indexed Properties accessible in a first class manner. Primary Interop Assemblies fit to the picture because they’re the way that COM interfaces are exposed into the managed world. In essence, they’re the bridge that allows you to use native COM “stuff” from your managed programming models. They are typically large API collections that must be deployed along with client applications.
What’s wrong with deploying PIAs?
Well, nothing’s wrong with it per se, but it certainly isn’t pleasant for developers who just want to write code against a COM API to have to worry about shipping the PIAs onto the client box, worry about whether or not it already exists on the client machine and what version lives there and all that. As I’ve mentioned before, you can think of the overarching theme of C# 4.0 as an interop release, one where we attempt to make interoping with different programming models and paradigms much simpler and much more first class.
Read more: Sam Ng's Blog
AutoCompleteComboBox for Silverlight
The built-in ComboBox in Silverlight is not powerful enough to cater our requirements of enterprise applications. In LOB (Line of business) applications, sometimes we need type-ahead behavior for combo boxes so that the available choices are filtered as the user starts typing. The AutoCompleteBox (previously included in Silverlight Toolkit but now a part of Silverlight 3 native controls) is a very powerful and flexible control, and in this article, we will look how we can customize the AutoCompleteBox to be used as a replacement for Combo Box/Drop Down.
What will we cover?
To begin the article, let's first define what functionalities we need to add to the AutoCompleteBox to make it behave like a type-ahead customizable drop down combo box. Here are our requirements:
- There should be a down-arrow like button that pops up the drop down with the available choices. Currently, the AutoCompleteBox is a simple textbox in its original shape.
- When an item is selected, bringing the drop down should show ALL the available choices. Currently, it only displays the selected one.
- If an item is selected and the drop down is opened, the selected item should be highlighted.
- The custom AutoCompleteBox should be useable for concrete object-to-object relationships (e.g.
SalesOrderDetail
object containing a reference to theProject
object, also called associations or navigational properties). - The custom implementation should be useable in foreign key relationships (e.g.
SalesOrderDetail
object containing a field calledProductID
).
Read more: CodeProject
The Quick and Easy on Using NMCap to Create Circular Network Traces Based on File Size
I wanted to take a minute to show you a quick way to utilize Network Monitor to perform Sequential, or also called Circular, captures for troubleshooting issues. This is particularly useful when you can’t dictate when the networking communications you are looking for are going to happen. This method of troubleshooting has been available via GUI configurations using other network traffic capture utilities but has been, and currently is, only available through the command line options provided with Network Monitor.
(NMCap is a tool that is installed when you install Network Monitor 3.x. This is a command line based tool that provides great a bit of functionality. As time goes by you will find more postings on other uses this tool can provide.)
As said before, the goal of this discussion is to describe how to collect a sequential trace. What I mean by that is that you set Netmon to create a trace that only grows so large… 200MB for example. Once the capture has grown to 200MB it will close the current file and create a new one. That file will grow up to 200MB and then create another file. This will provide you the ability to go back and review your files and look to see if the date/time stamp matches the date/time of when your possible problem may have occurred. Having this information helps because you can delete the trace files that you know do not meet your criteria. If you were to just start a trace file and walk away it could easily fill your hard drive or become so large that it will become too much of a burden to be open or parsed in a timely fashion.
Read more: Microsoft Enterprise Networking Team
Yahoo YUI Compressor vs. Microsoft AJAX Minifier vs. Google Closure Compiler
A little more than a year and half ago I created a MSBuild Task for the YUI Compressor that was very well received, and even highlighted on the YUI Compressor site. At the time of writing that article YUI Compressor was king of the hill, and for the most part the only game in town that was really designed for production level use. Since then a number of new competitors have been released by Google and Microsoft, and I wanted to see how they stacked up against the YUI Compressor.
Setup
For these tests I wanted to test a pretty complex set of JavaScript to really stretch the limits of each of the optimizers. So I choose jQuery 1.4 as the subject for the tests. I choose jQuery for many reasons, but the biggest is because it is very well known set of code for most developers, and it would be very easy for anybody to test in their applications.
The setup of my machine is as follows:
- Windows 7 Pro (x64)
- Java 6 Update 17
- .NET 3.5 SP1
Each optimizer and the version:
Read more: Nick Berardi's Coder Journal
50 Brilliant CSS3/JavaScript Coding Techniques - Smashing Magazine
When the light is turned on, the position and opacity of the logo shadow will change dynamically, depending on the position and distance of the light bulb. Don’t forget to drag the logo and/or the light bulb around!

Sun.com is dead now
Did you know about db4o – a brilliant object oriented database
Finding a Node in an XML String - Deborah's Developer MindScape
As with many of my prior XML examples, the XML string is as follows:
<States>
<State name="Wisconsin">
<Regions>
<Region name="Milwaukee">
<Area name="Mukwanago"/>
<Area name="Germantown"/>
</Region>
<Region name="Fox Valley">
<Area name="Oshkosh" />
<Area name="Appleton" />
</Region>
</Regions>
</State>
</States>
The code to find the node for the Milwaukee region is as follows:
In C#:
// Be sure to set a reference to System.Core and System.Xml.Linq
XElement states = XElement.Load("testXML.xml");
// Using LINQ
XElement foundNode;
var query = from XElement r in states.Descendants("Region")
where r.Attribute("name").Value == "Milwaukee"
select r;
foundNode = query.FirstOrDefault();
// Using Lambda expressions
foundNode = states.Descendants("Region").
Where(r => r.Attribute("name").Value ==
"Milwaukee").FirstOrDefault();
In VB:
' Be sure to set a reference to System.Core and System.Xml.Linq
Dim states As XElement = XElement.Load("testXML.xml")
' Using LINQ
Dim foundNode As XElement
Dim query = From r As XElement In states...<Region> _
Where r.@<name> = "Milwaukee"
foundNode = query.FirstOrDefault()
' Using Lambda expression
foundNode = states...<Region>.Where(Function(r) r.@<name> = _
"Milwaukee").FirstOrDefault
This code first loads the XML file containing the XML. The next set of code can be done using LINQ or using Lambda expressions. Use either one, but not both. :-)
The C# code uses the XElement properties and methods. The VB code uses XML literals.
NOTE: The XElement properties and methods work in VB as well.
Enjoy!
NOTE: This post was created based on a prior post that included both finding a node and adding new nodes. This post separates the first step to provide a more straightforward example.
Read more: Deborah's Developer MindScape
Visual Studio Tips and Tricks : Guidelines, a hidden feature for the Visual Studio Editor -- vstipEdit0015
Guidelines, a hidden feature for the Visual Studio Editor -- vstipEdit0015
So this is the first tip update I have done that has apparently been removed in VS2010. At the time of this writing I am talking with the VS editor folks to find out if the registry hack is, in fact, gone or just needs to go somewhere else. I will update this post if I discover any change.
With that said, if you are using Visual Studio 2010 there is an extension, created by Paul Harrington, you can use to have the guidelines:
http://visualstudiogallery.msdn.microsoft.com/en-us/0fbf2878-e678-4577-9fdb-9030389b338c
Read more: Visual Studio Tips and Tricks
User Account Control Step-by-Step Guide - Sent using Google Toolbar
This step-by-step guide provides the instructions necessary to use User Account Control (UAC) in a test environment.
This document is not intended to provide a comprehensive, detailed description of UAC. Additional resources include the following:
- All users of this step-by-step guide will also be interested in Getting Started with User Account Control on Windows Vista (http://go.microsoft.com/fwlink/?LinkID=102562).
- For additional information for IT professionals, see Understanding and Configuring User Account Control in Windows Vista (http://go.microsoft.com/fwlink/?LinkId=56402).
- For information for developers and independent software vendors about how to develop applications for Windows Vista® or Windows Server® 2008, see The Windows Vista and Windows Server 2008 Developer Story: Windows Vista Application Development Requirements for User Account Control (UAC) (http://go.microsoft.com/fwlink/?LinkId=89654).
What is User Account Control?
User Account Control (UAC) is a new security component in Windows Vista. UAC enables users to perform common tasks as non-administrators, called standard users in Windows Vista, and as administrators without having to switch users, log off, or use Run As. A standard user account is synonymous with a user account in Windows XP. User accounts that are members of the local Administrators group will run most applications as a standard user. By separating user and administrator functions while enabling productivity, UAC is an important enhancement for Windows Vista.
Read more: Technet