clockSeptember 7, 2009 13:37 by authorPaul Alexander commentComments (0)

When an application crashes on Windows 7 where Visual Studio is installed, you’re normally prompted to Debug the application (after waiting for it to check for issues :( ). However some applications always get caught by Dr. Watson and never give you a chance to debug. There are a few articles out there on disabling Dr. Watson for XP, but Vista and Windows 7 are different enough that the other techniques often fail to help.More...



clockAugust 7, 2009 01:09 by authorPaul Alexander commentComments (0)

While many of my entity classes use surrogate primary keys, they also have natural keys (Product SKU for example). When I want one of those entities it’s more natural to use the natural key, naturally. Normally that requires a CreateCriteria call, I’d rather just call Get<T> like I can with the surrogate keys. So I created an extension method that lets me do this:

var product = session.Get<Product>( x => x.Sku == “DLX” );
More...


clockJuly 19, 2009 06:37 by authorPaul Alexander commentComments (0)

Ever wished you could test the output of your MailMessages without actually sending the message anywhere? You could use the DeliveryMethod of the SmtpClient with SpecifiedPickupDirectory and try and round trip the email through the file system. This is troublesome as you have to remember to delete all the files in the output directory before calling Send, then scan the folder for the new file. It also prevents you from any sort of multi-threaded testing. More...



clockJune 3, 2009 15:31 by authorPaul Alexander commentComments (0)

From time to time I'll want to perform some operation on a subset of properties of a Type. However reflecting over types can be costly exercise. Since Types don't change at runtime the natural solution is to parse them once and cache the results. For small sets this works well. However  with hundreds of types, the performance starts to degrade. I've also noticed that the typeof operator is rather slow when compared to intrinsic is and as operators.

So to create a fast Type keyed dictionary I use the C# compiler and runtime JIT to do it for me. This solution is extremely fast and due to it's static nature, thread safe. But, it's also lazy-init because generic types aren't created until they're actually used at runtime.

public static class TypeCache<T>
{
	public static readonly Type Type = typeof( T );
	public static readonly PropertyInfo[] Properties = 
			typeof( T ).GetProperties();
}

I can now get all the properties of a type like this:

foreach( var p in TypeCache<Entity>.Properties )
{
	Console.WriteLine( p.Name );
}

Since this is all actually part of the runtime types, the JIT and compiler can take advantage of any available optimizations. Analysis of the actual code JITted at at runtime shows the lookup TypeCache<Entity> actually indexes into a runtime table, whereas the typeof operator does an actual lookup by signature.

Limitations

  • It's ready only. It's a great lazily initialized structure but the factors that make it thread safe.
  • It's never garbage collected. Type information is always retained in the AppDomain so any statics created this way will always remain live.


clockApril 23, 2009 16:30 by authorPaul Alexander commentComments (0)

We all love lambda expressions, WPF, threads and events. But mix them all together and you might run into some issues. Recently while writing some client application code I was hit by a problem with the dependency object automatic updates in WPF when the property is changed on thread other than the UI thread.More...



clockApril 20, 2009 23:22 by authorPaul Alexander commentComments (0)

For some reason, every project in my solution has decided to rebuild every time I try to build the solution – even if that particular project has no changes and none of the dependent projects have any changes. I thought it might have been cause by my recent change to turn Copy Local off for inter-solution references to help speed up the build process. But even reverting the code didn’t seem to fix it. Deleting the .suo and .user files that Visual Studio keeps it’s editor state in didn’t help either. So I decided to track down the issue. More...



clockApril 2, 2009 09:55 by authorGary Maccie commentComments (0)

As some of you readers may know I recently posted about JetBrains ReSharper. This handy tool had some set backs that I mentioned but overall the impact was a useful improvement over the standard Visual Studio utilities. Well, I’m here to report on the latest release that JetBrains is offering for their ReSharper line.

More...



clockMarch 26, 2009 01:35 by authorPaul Alexander commentComments (0)

From time to time .NET developers will need to use a native Win32 API to get some platform specific work done. One of the first things I ask myself when I start writing out Interop signatures is “Does the .NET framework already support this?”. The breadth of classes in the framework can be daunting and it’s not always easy to answer that question. Often the conversations and references online revolve around the native API so that isn’t always a help. Searching the MSDN docs can also lead to dead ends as the concepts and naming conventions are often modernized in the framework.

More...



clockMarch 25, 2009 18:55 by authorPaul Alexander commentComments (0)

When developing web applications I like to use FQDN when testing locally. Primarily because it more closely matches the deployed state of the application. Cookies have specific rules when sub-domains come into play and you’re much more likely to catch any variances. Traditionally I’d set just edit the hosts file on my dev machine (at C:\Windows\System32\drivers\etc on most machines) like so:

127.0.0.1			xheo.local
127.0.0.1			www.xheo.local
127.0.0.1			secure.xheo.local

So now I can type http://www.xheo.local and access my local IIS or Visual Studio web server. When the development team expanded we had to do this on each machine. While not really that difficult to do, I was curious if there was a way to apply the change across the entire network. Since we recently added a Windows domain server to the network with it’s built in DNS the change is simple. I can add a top-level .local domain to the forest and setup a wildcard host name to resolve to 127.0.0.1. It looks like this:

Localdomain

Now any machine on our network can type any .xheo.local address and it will resolve to their local machine. Sweet!



clockMarch 25, 2009 12:43 by authorGary Maccie commentComments (1)

So it wasn’t too long ago that XHEO developers implemented ReSharper into our development process. Personally ReSharper has been met with mixed emotions, especially for me.

More...



Products : News : Store : Search : Contact : About XHEO : Site Map
Copyright © 2002-2009 XHEO INC. All Rights Reserved.

XHEO.com: Copy Protection. Encryption. Deployment.
Copyright © 2002-2009 XHEO INC. All Rights Reserved.