<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://lyon-smith.org/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>lyon-smith.org</title><link>http://lyon-smith.org/blogs/default.aspx</link><description>The Lyon-Smith family web site.</description><dc:language>en-US</dc:language><generator>CommunityServer 2.1 SP1 (Build: 61025.2)</generator><item><title>C++ placement new and delete</title><link>http://lyon-smith.org/blogs/code-o-rama/archive/2008/02/16/c-placement-new-and-delete.aspx</link><pubDate>Sun, 17 Feb 2008 00:44:13 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:182</guid><dc:creator>john</dc:creator><slash:comments>0</slash:comments><description>&lt;p&gt;I was trying to write some debug memory allocation routines the other day and I decided I would attempt to use placement new.&amp;nbsp;&amp;nbsp; I hunted down some useful references:&lt;/p&gt; &lt;ul&gt; &lt;li&gt;&lt;a href="http://venus.cs.qc.edu/~waxman/780/placementnew.html"&gt;Placement new &amp;amp; delete&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="http://www.informit.com/guides/content.aspx?g=cplusplus&amp;amp;seqNum=304"&gt;informIT: C++ reference guide&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="http://www.informit.com/guides/content.aspx?g=cplusplus&amp;amp;seqNum=304"&gt;jaredpar's WebLog&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt; &lt;p&gt;If you are not familiar with the syntax it goes like this:&lt;/p&gt;&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;extern&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt;* ::&lt;span class="kwrd"&gt;operator&lt;/span&gt; &lt;span class="kwrd"&gt;new&lt;/span&gt;(size_t size, &lt;span class="kwrd"&gt;char&lt;/span&gt;* pLine, &lt;span class="kwrd"&gt;int&lt;/span&gt; line);
...
&lt;span class="kwrd"&gt;char&lt;/span&gt;* p = ::&lt;span class="kwrd"&gt;new&lt;/span&gt;(__FILE__, __LINE__) &lt;span class="kwrd"&gt;char&lt;/span&gt;[100];&lt;/pre&gt;
&lt;p&gt;The first line shows how to declare an override of the new operator with two placement arguments, in this case a char* and int which would allow you to record the location of the allocation.&lt;/p&gt;
&lt;p&gt;The logical extension to this mechanism is to actually create a placement override that passes a function pointer or a class instance to use for the memory allocation, like this:&lt;/p&gt;&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;extern&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt;* ::&lt;span class="kwrd"&gt;operator&lt;/span&gt; &lt;span class="kwrd"&gt;new&lt;/span&gt;(size_t size, Allocator* pAllocator);
...
&lt;span class="kwrd"&gt;char&lt;/span&gt;* p = ::&lt;span class="kwrd"&gt;new&lt;/span&gt;(pAllocator) &lt;span class="kwrd"&gt;char&lt;/span&gt;[100];&lt;/pre&gt;
&lt;p&gt;Seems all well and good, but how do we delete memory allocated using placement new?&amp;nbsp; There must be a placement delete, right?&amp;nbsp; Well, there is but as with most things in the committee designed C++ language it doesn't work the way you might expect.&lt;/p&gt;
&lt;p&gt;You can indeed declare a placement delete operator overload:&lt;/p&gt;&lt;pre class="csharpcode"&gt;&lt;span class="kwrd"&gt;extern&lt;/span&gt; &lt;span class="kwrd"&gt;void&lt;/span&gt; ::&lt;span class="kwrd"&gt;operator&lt;/span&gt; delete(&lt;span class="kwrd"&gt;void&lt;/span&gt;* p, Allocator* pAllocator);
...
::delete(pAllocator) p;  &lt;span class="rem"&gt;// This doesn't compile!&lt;/span&gt;
p-&amp;gt;~ClassName(); pAllocator-&amp;gt;Delete(p);  
&lt;/pre&gt;
.csharpcode, .csharpcode pre
{
	font-size: small;
	color: black;
	font-family: consolas, "Courier New", courier, monospace;
	background-color: #ffffff;
	/*white-space: pre;*/
}
.csharpcode pre { margin: 0em; }
.csharpcode .rem { color: #008000; }
.csharpcode .kwrd { color: #0000ff; }
.csharpcode .str { color: #006080; }
.csharpcode .op { color: #0000c0; }
.csharpcode .preproc { color: #cc6633; }
.csharpcode .asp { background-color: #ffff00; }
.csharpcode .html { color: #800000; }
.csharpcode .attr { color: #ff0000; }
.csharpcode .alt 
{
	background-color: #f4f4f4;
	width: 100%;
	margin: 0em;
}
.csharpcode .lnum { color: #606060; }


&lt;p&gt;The ::delete line doesn't compile.&amp;nbsp; The fact is, you can't explicitly call placement delete, making it effectively useless in my opinion for many uses.&amp;nbsp; You must explicitly call any class destructor and your allocator's Delete or Free method.&lt;/p&gt;
&lt;p&gt;So why use is it to create placement new override?&amp;nbsp; Well, it turns out that if you classes constructor throws an exception then the appropriate placement delete override will get called.&amp;nbsp; How nutty is that!&amp;nbsp; The compiler knows enough to use the placement delete properly, but there's not C++ syntax to expose it for general use!&amp;nbsp; &lt;/p&gt;
&lt;p&gt;The need to explicitly call destructors and clean-up memory is particularly annoying when allocating arrays of objects.&amp;nbsp; You must loop through all your objects calling destructors, etc..&amp;nbsp; Good luck creating a macro or a template to simplify things.&lt;/p&gt;
&lt;p&gt;In my opinion, creating placement delete syntax is entirely feasible for compiler writers.&amp;nbsp; The compiler knows all about the types of the classes involved, whether they are arrays, etc..&amp;nbsp; Hopefully this idea will work it's way through a future C++ committee meeting.&lt;/p&gt;&lt;img src="http://lyon-smith.org/aggbug.aspx?PostID=182" width="1" height="1"&gt;</description></item><item><title>Correct Comparisons for files and paths in .NET</title><link>http://lyon-smith.org/blogs/code-o-rama/archive/2008/02/01/correct-comparisons-for-files-and-paths-in-net.aspx</link><pubDate>Fri, 01 Feb 2008 20:36:23 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:181</guid><dc:creator>john</dc:creator><slash:comments>0</slash:comments><description>&lt;p&gt;So exactly how should you compare file and path names in .NET programs?&amp;nbsp; Ordinal case insensitive comparisons are the correct approach according to &lt;a href="http://msdn2.microsoft.com/en-us/library/ms973919.aspx#stringsinnet20_topic9" target="_blank"&gt;this MSDN article&lt;/a&gt;.&lt;/p&gt;&lt;img src="http://lyon-smith.org/aggbug.aspx?PostID=181" width="1" height="1"&gt;</description><category domain="http://lyon-smith.org/blogs/code-o-rama/archive/tags/.net+2.0/default.aspx">.net 2.0</category><category domain="http://lyon-smith.org/blogs/code-o-rama/archive/tags/c_2300_/default.aspx">c#</category><category domain="http://lyon-smith.org/blogs/code-o-rama/archive/tags/coding/default.aspx">coding</category><category domain="http://lyon-smith.org/blogs/code-o-rama/archive/tags/.net+3.5/default.aspx">.net 3.5</category></item><item><title>CPU-Z and CPU Information</title><link>http://lyon-smith.org/blogs/code-o-rama/archive/2008/01/17/cpu-z-and-cpu-information.aspx</link><pubDate>Thu, 17 Jan 2008 19:06:33 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:180</guid><dc:creator>john</dc:creator><slash:comments>0</slash:comments><description>&lt;p&gt;My colleague Sergey just showed me a useful tool for getting CPU information on your Windows hardware system called &lt;a href="http://www.cpuid.com/cpuz.php" target="_blank"&gt;CPU-Z&lt;/a&gt;.&lt;/p&gt;&lt;img src="http://lyon-smith.org/aggbug.aspx?PostID=180" width="1" height="1"&gt;</description><category domain="http://lyon-smith.org/blogs/code-o-rama/archive/tags/windows/default.aspx">windows</category><category domain="http://lyon-smith.org/blogs/code-o-rama/archive/tags/hardware/default.aspx">hardware</category></item><item><title>Personal Rapid Transit</title><link>http://lyon-smith.org/blogs/ktthp/archive/2008/01/07/personal-rapid-transit.aspx</link><pubDate>Mon, 07 Jan 2008 17:34:00 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:179</guid><dc:creator>john</dc:creator><slash:comments>0</slash:comments><description>&lt;P&gt;&lt;IMG hspace=10 src="http://gettherefast.org/systempix/bc-ms02th.jpg" align=left&gt; This &lt;A href="http://gettherefast.org/bettercampus.html" target=_blank&gt;Personal Rapid Transit (PRT)&lt;/A&gt; proposal is still one of the coolest ideas for improving the commuting situation that I have seen.&amp;nbsp;&amp;nbsp; Microsoft has a really large corporate campus with buildings spread out over many square miles.&amp;nbsp; Going to meetings in another building today involves driving yourself, taking a campus bus or walking.&amp;nbsp; Given the choice I'd walk rain or shine, but often you don't have enough time to leave the extra 10 - 20 minutes at each end of the meeting.&amp;nbsp; And some buildings are too far away to walk too. &lt;/P&gt;
&lt;P&gt;In any case, I'd like to see a system like this adopted for an even wider audience than just one company.&amp;nbsp; Wouldn't it be great to be able to get on one of these at the end of your road and shoot all the way to work or into town.&amp;nbsp; It would beat the pants of today's grubby and inconvenient mass transit systems.&lt;/P&gt;&lt;img src="http://lyon-smith.org/aggbug.aspx?PostID=179" width="1" height="1"&gt;</description><category domain="http://lyon-smith.org/blogs/ktthp/archive/tags/life/default.aspx">life</category><category domain="http://lyon-smith.org/blogs/ktthp/archive/tags/viral+video/default.aspx">viral video</category><category domain="http://lyon-smith.org/blogs/ktthp/archive/tags/cars/default.aspx">cars</category><category domain="http://lyon-smith.org/blogs/ktthp/archive/tags/microsoft/default.aspx">microsoft</category><category domain="http://lyon-smith.org/blogs/ktthp/archive/tags/science/default.aspx">science</category><category domain="http://lyon-smith.org/blogs/ktthp/archive/tags/transport/default.aspx">transport</category><category domain="http://lyon-smith.org/blogs/ktthp/archive/tags/commuting/default.aspx">commuting</category></item><item><title>Dynamic Code Generation in .NET</title><link>http://lyon-smith.org/blogs/code-o-rama/archive/2008/01/05/dynamic-code-generation-in-net.aspx</link><pubDate>Sat, 05 Jan 2008 23:08:00 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:178</guid><dc:creator>john</dc:creator><slash:comments>0</slash:comments><description>&lt;P&gt;I recently had the need/desire to dynamically generate some code in .NET.&amp;nbsp; It's not something you tend to do a lot unless you are creating a compiler, so it was an interesting experience.&amp;nbsp; In the end it didn't solve my problem, but it was educational none-the-less.&lt;/P&gt;
&lt;P&gt;First I'll describe the scenario of the problem I was trying to solve using dynamically generated code, then I'll discuss how I went about generating the code and problems that hit and so on.&lt;/P&gt;
&lt;P&gt;The problem has to do with assembly resolution in .NET.&amp;nbsp; I wanted to launch a program B in a separate appdomain from program A.&amp;nbsp; Program B is in a completely different directory than A.&amp;nbsp; Program B ultimately wants to load assemblies that are not in the GAC and are not in the same directory as it or in any of it's sub-directories.&amp;nbsp; One way around this problem is to play games with probing paths and .config files.&amp;nbsp; That works but it doesn't work if the assemblies are on a different drive.&amp;nbsp; What I decided I wanted to do was to inject an AssemblyResolve handler into program B and provide a search path from program A.&amp;nbsp; I could have done this by writing the AssemblyResolve handler in C#, creating an assembly and then loading that assembly into program B and wiring up the handler.&amp;nbsp; It would be cleaner (but a more work) to dynamically generate the assembly as needed.&amp;nbsp; For entertainment value I went with the latter plan.&lt;/P&gt;
&lt;P&gt;First, lets set up some test programs so we can establish the scenario.&amp;nbsp; We need a test assembly that's just going to be the fodder for our experiment:&lt;/P&gt;&lt;PRE class=csharpcode&gt;&lt;SPAN class=kwrd&gt;using&lt;/SPAN&gt; System;

&lt;SPAN class=kwrd&gt;public&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;class&lt;/SPAN&gt; TestClass
{
    &lt;SPAN class=kwrd&gt;public&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;void&lt;/SPAN&gt; TestMethod()
    {
        Console.WriteLine(&lt;SPAN class=str&gt;"In TestClass.TestMethod"&lt;/SPAN&gt;);
    }
}&lt;/PRE&gt;
&lt;P&gt;Now program B, &lt;STRONG&gt;TestLoader&lt;/STRONG&gt;, which is basically going to take an assembly name on the command line, attempt to load it and create an instance of &lt;STRONG&gt;TestClass&lt;/STRONG&gt; and call &lt;STRONG&gt;TestMethod&lt;/STRONG&gt;.&lt;/P&gt;&lt;PRE class=csharpcode&gt;&lt;SPAN class=kwrd&gt;using&lt;/SPAN&gt; System;
&lt;SPAN class=kwrd&gt;using&lt;/SPAN&gt; System.IO;
&lt;SPAN class=kwrd&gt;using&lt;/SPAN&gt; System.Reflection;

&lt;SPAN class=kwrd&gt;public&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;class&lt;/SPAN&gt; Program
{
&lt;SPAN class=preproc&gt;#if&lt;/SPAN&gt; ASSEMBLY_RESOLVE
    &lt;SPAN class=kwrd&gt;public&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;static&lt;/SPAN&gt; Assembly OnAssemblyResolve(&lt;SPAN class=kwrd&gt;object&lt;/SPAN&gt; sender, ResolveEventArgs args)
    {
        Console.WriteLine(&lt;SPAN class=str&gt;"Resolving assembly "&lt;/SPAN&gt;);
        Console.WriteLine(args.Name);
        
        &lt;SPAN class=kwrd&gt;string&lt;/SPAN&gt;[] searchDirs = ((&lt;SPAN class=kwrd&gt;string&lt;/SPAN&gt;)AppDomain.CurrentDomain.GetData(&lt;SPAN class=str&gt;"SEARCHPATH"&lt;/SPAN&gt;)).Split(&lt;SPAN class=kwrd&gt;new&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;char&lt;/SPAN&gt;[] { &lt;SPAN class=str&gt;';'&lt;/SPAN&gt; }, StringSplitOptions.RemoveEmptyEntries);
        &lt;SPAN class=kwrd&gt;int&lt;/SPAN&gt; index = args.Name.IndexOf(&lt;SPAN class=str&gt;','&lt;/SPAN&gt;);
        
        &lt;SPAN class=kwrd&gt;if&lt;/SPAN&gt; (index == -1)
            index = args.Name.Length;
        
        &lt;SPAN class=kwrd&gt;string&lt;/SPAN&gt; name = args.Name.Substring(0, index);

        &lt;SPAN class=kwrd&gt;for&lt;/SPAN&gt; (&lt;SPAN class=kwrd&gt;int&lt;/SPAN&gt; i = 0; i &amp;lt; searchDirs.Length; i++)
        {
            &lt;SPAN class=kwrd&gt;string&lt;/SPAN&gt; assemblyPath = Path.Combine(searchDirs[i], name) + &lt;SPAN class=str&gt;".dll"&lt;/SPAN&gt;;
            
            &lt;SPAN class=kwrd&gt;if&lt;/SPAN&gt; (File.Exists(assemblyPath))
                &lt;SPAN class=kwrd&gt;return&lt;/SPAN&gt; Assembly.LoadFrom(assemblyPath);
        }

        &lt;SPAN class=kwrd&gt;return&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;null&lt;/SPAN&gt;;
    }
&lt;SPAN class=preproc&gt;#endif&lt;/SPAN&gt;

    &lt;SPAN class=kwrd&gt;public&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;static&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;int&lt;/SPAN&gt; Main(&lt;SPAN class=kwrd&gt;string&lt;/SPAN&gt;[] args)
    {
&lt;SPAN class=preproc&gt;#if&lt;/SPAN&gt; ASSEMBLY_RESOLVE
        &lt;SPAN class=kwrd&gt;if&lt;/SPAN&gt; (args.Length != 2)
        {
            Console.WriteLine(&lt;SPAN class=str&gt;"TestLoader &amp;lt;assembly-name&amp;gt; &amp;lt;path&amp;gt;"&lt;/SPAN&gt;);
            &lt;SPAN class=kwrd&gt;return&lt;/SPAN&gt; 1;
        }

        AppDomain.CurrentDomain.SetData(&lt;SPAN class=str&gt;"SEARCHPATH"&lt;/SPAN&gt;, args[1]);
        AppDomain.CurrentDomain.AssemblyResolve += OnAssemblyResolve;
&lt;SPAN class=preproc&gt;#else&lt;/SPAN&gt;
        &lt;SPAN class=kwrd&gt;if&lt;/SPAN&gt; (args.Length != 1)
        {
            Console.WriteLine(&lt;SPAN class=str&gt;"TestLoader &amp;lt;assembly-name&amp;gt;"&lt;/SPAN&gt;);
            &lt;SPAN class=kwrd&gt;return&lt;/SPAN&gt; 1;
        }
&lt;SPAN class=preproc&gt;#endif&lt;/SPAN&gt;

        &lt;SPAN class=kwrd&gt;try&lt;/SPAN&gt;
        {
            Assembly assembly = Assembly.Load(args[0]);
            Type type = assembly.GetType(&lt;SPAN class=str&gt;"TestClass"&lt;/SPAN&gt;);
            MethodInfo methodInfo = type.GetMethod(&lt;SPAN class=str&gt;"TestMethod"&lt;/SPAN&gt;);
            &lt;SPAN class=kwrd&gt;object&lt;/SPAN&gt; obj = Activator.CreateInstance(type);
            
            methodInfo.Invoke(obj, &lt;SPAN class=kwrd&gt;null&lt;/SPAN&gt;);
        }
        &lt;SPAN class=kwrd&gt;catch&lt;/SPAN&gt; (Exception e)
        {
            Console.WriteLine(e);
        }
        
        &lt;SPAN class=kwrd&gt;return&lt;/SPAN&gt; 0;
    }
}
&lt;/PRE&gt;
&lt;P&gt;So what's going on here then?&amp;nbsp; Firstly, ignore the code inside the ASSEMBLY_RESOLVE macro.&amp;nbsp; What this code does without that is to try to load the assembly name given on the path.&amp;nbsp; It's expecting a full or partially qualified strong name, not a file path.&lt;/P&gt;
&lt;P&gt;Compile the test assembly code into a .dll in one directory call &lt;STRONG&gt;TestAssembly&lt;/STRONG&gt;.&amp;nbsp; Then compile program B in another directory call &lt;STRONG&gt;TestLoader &lt;/STRONG&gt;as a .exe.&amp;nbsp;&amp;nbsp; Run it specifying &lt;STRONG&gt;TestAssembly &lt;/STRONG&gt;as an argument.&amp;nbsp;&amp;nbsp; Of course the &lt;STRONG&gt;Load()&lt;/STRONG&gt; generates an exception.&amp;nbsp; Let's assume we decide to solve this problem by adding an &lt;STRONG&gt;AssemblyResolve&lt;/STRONG&gt; handler.&amp;nbsp;&amp;nbsp; Recompile program B with &lt;STRONG&gt;/d:ASSEMBLY_RESOLVE &lt;/STRONG&gt;defined.&amp;nbsp; Now run it specifying &lt;STRONG&gt;TestAssembly ..\TestAssembly&lt;/STRONG&gt; as arguments.&amp;nbsp; You can see by examining the code and looking at the output how the &lt;STRONG&gt;AssemblyResolve&lt;/STRONG&gt; event handler saves the day when the CLR cannot find the assembly using its normal probing locations (GAC, local directory, special sub-directories).&amp;nbsp; Before we continue, recompile program B without &lt;STRONG&gt;ASSEMBLY_RESOLVE &lt;/STRONG&gt;defined.&lt;/P&gt;
&lt;P&gt;Now we move on to program A, &lt;STRONG&gt;TestLoaderWrapper&lt;/STRONG&gt;, the wrapper that will dynamically "inject" the assembly resolve event handler.&amp;nbsp; Imagine that &lt;STRONG&gt;TestLoader&lt;/STRONG&gt; was some code that you did not have the source code for.&amp;nbsp; We're going to try change it's assembly loading behavior externally.&amp;nbsp; &lt;/P&gt;
&lt;P&gt;Here's the code for &lt;STRONG&gt;TestLoaderWrapper&lt;/STRONG&gt;.&amp;nbsp; It's a bit scary:&lt;/P&gt;&lt;PRE class=csharpcode&gt;&lt;SPAN class=kwrd&gt;using&lt;/SPAN&gt; System;
&lt;SPAN class=kwrd&gt;using&lt;/SPAN&gt; System.IO;
&lt;SPAN class=kwrd&gt;using&lt;/SPAN&gt; System.Reflection;
&lt;SPAN class=kwrd&gt;using&lt;/SPAN&gt; System.Reflection.Emit;

&lt;SPAN class=kwrd&gt;public&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;class&lt;/SPAN&gt; Program
{
    &lt;SPAN class=kwrd&gt;public&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;static&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;int&lt;/SPAN&gt; Main(&lt;SPAN class=kwrd&gt;string&lt;/SPAN&gt;[] args)
    {
        &lt;SPAN class=kwrd&gt;if&lt;/SPAN&gt; (args.Length != 2)
        {
            Console.WriteLine(&lt;SPAN class=str&gt;"LoadTestWrapper &amp;lt;assembly-name&amp;gt; &amp;lt;search-path&amp;gt;"&lt;/SPAN&gt;);
            &lt;SPAN class=kwrd&gt;return&lt;/SPAN&gt; 1;
        }
    
        AppDomain appDomain = AppDomain.CreateDomain(&lt;SPAN class=str&gt;"NewDomain"&lt;/SPAN&gt;);
        
        &lt;SPAN class=rem&gt;// Set the search path in the new domain using domain data&lt;/SPAN&gt;
        appDomain.SetData(&lt;SPAN class=str&gt;"SEARCHPATH"&lt;/SPAN&gt;, args[1]);

        &lt;SPAN class=rem&gt;// Dynamically create an assembly containing our assembly resolver&lt;/SPAN&gt;
        AssemblyName assemblyName = &lt;SPAN class=kwrd&gt;new&lt;/SPAN&gt; AssemblyName();

        assemblyName.Name = &lt;SPAN class=str&gt;"AssemblyResolver"&lt;/SPAN&gt;;

        &lt;SPAN class=kwrd&gt;string&lt;/SPAN&gt; assemblyFile = assemblyName.Name + &lt;SPAN class=str&gt;".dll"&lt;/SPAN&gt;;
        AssemblyBuilder assemblyBuilder = AppDomain.CurrentDomain.DefineDynamicAssembly(assemblyName, AssemblyBuilderAccess.RunAndSave);
        ModuleBuilder moduleBuilder = assemblyBuilder.DefineDynamicModule(assemblyName.Name, assemblyFile);
        TypeBuilder typeBuilder = moduleBuilder.DefineType(&lt;SPAN class=str&gt;"Handler"&lt;/SPAN&gt;, TypeAttributes.Class | TypeAttributes.Public);
        MethodBuilder methodBuilder = typeBuilder.DefineMethod(&lt;SPAN class=str&gt;"OnAssemblyResolve"&lt;/SPAN&gt;,
            MethodAttributes.Public | MethodAttributes.Static,
            &lt;SPAN class=kwrd&gt;typeof&lt;/SPAN&gt;(Assembly), &lt;SPAN class=kwrd&gt;new&lt;/SPAN&gt; Type[] { &lt;SPAN class=kwrd&gt;typeof&lt;/SPAN&gt;(&lt;SPAN class=kwrd&gt;object&lt;/SPAN&gt;), &lt;SPAN class=kwrd&gt;typeof&lt;/SPAN&gt;(System.ResolveEventArgs) });

        GenerateAssemblyResolveMethod(methodBuilder.GetILGenerator());

        Type handlerType = typeBuilder.CreateType();
        MethodInfo onAssemblyResolve = handlerType.GetMethod(&lt;SPAN class=str&gt;"OnAssemblyResolve"&lt;/SPAN&gt;);

        &lt;SPAN class=rem&gt;// You cannot specify a path in the saved assembly, so we must copy it next to the assembly&lt;/SPAN&gt;
        &lt;SPAN class=rem&gt;// we will be running so that the CLR loader can find it.&lt;/SPAN&gt;
        &lt;SPAN class=kwrd&gt;string&lt;/SPAN&gt; targetAssemblyPath = Path.Combine(&lt;SPAN class=str&gt;@"..\TestLoader"&lt;/SPAN&gt;, assemblyFile);

        assemblyBuilder.Save(assemblyFile);

        File.Copy(assemblyFile, targetAssemblyPath, &lt;SPAN class=kwrd&gt;true&lt;/SPAN&gt;);

        Delegate handlerDelegate = Delegate.CreateDelegate(&lt;SPAN class=kwrd&gt;typeof&lt;/SPAN&gt;(ResolveEventHandler), onAssemblyResolve);
        EventInfo assemblyResolveEvent = &lt;SPAN class=kwrd&gt;typeof&lt;/SPAN&gt;(AppDomain).GetEvent(&lt;SPAN class=str&gt;"AssemblyResolve"&lt;/SPAN&gt;);

        assemblyResolveEvent.AddEventHandler(appDomain, handlerDelegate);
        
        appDomain.ExecuteAssembly(&lt;SPAN class=str&gt;@"..\TestLoader\TestLoader.exe"&lt;/SPAN&gt;, AppDomain.CurrentDomain.Evidence, 
            &lt;SPAN class=kwrd&gt;new&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;string&lt;/SPAN&gt;[] { args[0] });

        &lt;SPAN class=kwrd&gt;return&lt;/SPAN&gt; 0;
    }

    &lt;SPAN class=kwrd&gt;public&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;static&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;void&lt;/SPAN&gt; GenerateAssemblyResolveMethod(ILGenerator il)
    {
        Type consoleType = &lt;SPAN class=kwrd&gt;typeof&lt;/SPAN&gt;(System.Console);
        MethodInfo write = consoleType.GetMethod(&lt;SPAN class=str&gt;"Write"&lt;/SPAN&gt;, BindingFlags.Public | BindingFlags.Static, &lt;SPAN class=kwrd&gt;null&lt;/SPAN&gt;, &lt;SPAN class=kwrd&gt;new&lt;/SPAN&gt; Type[] {&lt;SPAN class=kwrd&gt;typeof&lt;/SPAN&gt;(&lt;SPAN class=kwrd&gt;string&lt;/SPAN&gt;)}, &lt;SPAN class=kwrd&gt;null&lt;/SPAN&gt;);
        MethodInfo writeLine = consoleType.GetMethod(&lt;SPAN class=str&gt;"WriteLine"&lt;/SPAN&gt;, BindingFlags.Public | BindingFlags.Static, &lt;SPAN class=kwrd&gt;null&lt;/SPAN&gt;, &lt;SPAN class=kwrd&gt;new&lt;/SPAN&gt; Type[] {&lt;SPAN class=kwrd&gt;typeof&lt;/SPAN&gt;(&lt;SPAN class=kwrd&gt;string&lt;/SPAN&gt;)}, &lt;SPAN class=kwrd&gt;null&lt;/SPAN&gt;);
        Type appDomainType = &lt;SPAN class=kwrd&gt;typeof&lt;/SPAN&gt;(System.AppDomain);
        MethodInfo getCurrentDomain = appDomainType.GetMethod(&lt;SPAN class=str&gt;"get_CurrentDomain"&lt;/SPAN&gt;);
        MethodInfo getData = appDomainType.GetMethod(&lt;SPAN class=str&gt;"GetData"&lt;/SPAN&gt;);
        Type assemblyType = &lt;SPAN class=kwrd&gt;typeof&lt;/SPAN&gt;(System.Reflection.Assembly);
        MethodInfo loadFrom = assemblyType.GetMethod(&lt;SPAN class=str&gt;"LoadFrom"&lt;/SPAN&gt;, &lt;SPAN class=kwrd&gt;new&lt;/SPAN&gt; Type[] { &lt;SPAN class=kwrd&gt;typeof&lt;/SPAN&gt;(&lt;SPAN class=kwrd&gt;string&lt;/SPAN&gt;) });
        Type resolveEventArgs = &lt;SPAN class=kwrd&gt;typeof&lt;/SPAN&gt;(System.ResolveEventArgs);
        MethodInfo getName = resolveEventArgs.GetMethod(&lt;SPAN class=str&gt;"get_Name"&lt;/SPAN&gt;);
        Type stringType = &lt;SPAN class=kwrd&gt;typeof&lt;/SPAN&gt;(&lt;SPAN class=kwrd&gt;string&lt;/SPAN&gt;);
        MethodInfo splitMethod = stringType.GetMethod(&lt;SPAN class=str&gt;"Split"&lt;/SPAN&gt;, &lt;SPAN class=kwrd&gt;new&lt;/SPAN&gt; Type[] { &lt;SPAN class=kwrd&gt;typeof&lt;/SPAN&gt;(&lt;SPAN class=kwrd&gt;char&lt;/SPAN&gt;[]), &lt;SPAN class=kwrd&gt;typeof&lt;/SPAN&gt;(StringSplitOptions) });
        MethodInfo substring = stringType.GetMethod(&lt;SPAN class=str&gt;"Substring"&lt;/SPAN&gt;, &lt;SPAN class=kwrd&gt;new&lt;/SPAN&gt; Type[] { &lt;SPAN class=kwrd&gt;typeof&lt;/SPAN&gt;(&lt;SPAN class=kwrd&gt;int&lt;/SPAN&gt;), &lt;SPAN class=kwrd&gt;typeof&lt;/SPAN&gt;(&lt;SPAN class=kwrd&gt;int&lt;/SPAN&gt;) });
        MethodInfo indexOf = stringType.GetMethod(&lt;SPAN class=str&gt;"IndexOf"&lt;/SPAN&gt;, &lt;SPAN class=kwrd&gt;new&lt;/SPAN&gt; Type[] { &lt;SPAN class=kwrd&gt;typeof&lt;/SPAN&gt;(&lt;SPAN class=kwrd&gt;char&lt;/SPAN&gt;) });
        MethodInfo concat = stringType.GetMethod(&lt;SPAN class=str&gt;"Concat"&lt;/SPAN&gt;, &lt;SPAN class=kwrd&gt;new&lt;/SPAN&gt; Type[] { &lt;SPAN class=kwrd&gt;typeof&lt;/SPAN&gt;(&lt;SPAN class=kwrd&gt;string&lt;/SPAN&gt;), &lt;SPAN class=kwrd&gt;typeof&lt;/SPAN&gt;(&lt;SPAN class=kwrd&gt;string&lt;/SPAN&gt;) });
        MethodInfo getLength = stringType.GetMethod(&lt;SPAN class=str&gt;"get_Length"&lt;/SPAN&gt;);
        Type pathType = &lt;SPAN class=kwrd&gt;typeof&lt;/SPAN&gt;(System.IO.Path);
        MethodInfo combine = pathType.GetMethod(&lt;SPAN class=str&gt;"Combine"&lt;/SPAN&gt;, BindingFlags.Public | BindingFlags.Static);
        Type fileType = &lt;SPAN class=kwrd&gt;typeof&lt;/SPAN&gt;(System.IO.File);
        MethodInfo exists = fileType.GetMethod(&lt;SPAN class=str&gt;"Exists"&lt;/SPAN&gt;, BindingFlags.Public | BindingFlags.Static);

        &lt;SPAN class=rem&gt;// Console.Write("Resolving assembly ");&lt;/SPAN&gt;
        il.Emit(OpCodes.Ldstr, &lt;SPAN class=str&gt;"Resolving assembly "&lt;/SPAN&gt;);      &lt;SPAN class=rem&gt;// -&amp;gt; T&lt;/SPAN&gt;
        il.EmitCall(OpCodes.Call, write, &lt;SPAN class=kwrd&gt;null&lt;/SPAN&gt;);             &lt;SPAN class=rem&gt;// -&amp;gt;&lt;/SPAN&gt;

        &lt;SPAN class=rem&gt;// Console.WriteLine(args.Name);&lt;/SPAN&gt;
        il.Emit(OpCodes.Ldarg, 1);                          &lt;SPAN class=rem&gt;// -&amp;gt; T&lt;/SPAN&gt;
        il.EmitCall(OpCodes.Callvirt, getName, &lt;SPAN class=kwrd&gt;null&lt;/SPAN&gt;);       &lt;SPAN class=rem&gt;// -&amp;gt; T&lt;/SPAN&gt;
        il.EmitCall(OpCodes.Call, writeLine, &lt;SPAN class=kwrd&gt;null&lt;/SPAN&gt;);         &lt;SPAN class=rem&gt;// -&amp;gt; &lt;/SPAN&gt;

        &lt;SPAN class=rem&gt;// string[] searchDirs = ((string)AppDomain.CurrentDomain.GetData("SEARCHPATH")).Split(new char[] {';'}, StringSplitOptions.RemoveEmptyEntries);&lt;/SPAN&gt;
        LocalBuilder searchDirs = il.DeclareLocal(&lt;SPAN class=kwrd&gt;typeof&lt;/SPAN&gt;(&lt;SPAN class=kwrd&gt;string&lt;/SPAN&gt;[]));

        il.EmitCall(OpCodes.Call, getCurrentDomain, &lt;SPAN class=kwrd&gt;null&lt;/SPAN&gt;);  &lt;SPAN class=rem&gt;// -&amp;gt; T&lt;/SPAN&gt;
        il.Emit(OpCodes.Ldstr, &lt;SPAN class=str&gt;"SEARCHPATH"&lt;/SPAN&gt;);               &lt;SPAN class=rem&gt;// -&amp;gt; T, T&lt;/SPAN&gt;
        il.EmitCall(OpCodes.Callvirt, getData, &lt;SPAN class=kwrd&gt;null&lt;/SPAN&gt;);       &lt;SPAN class=rem&gt;// -&amp;gt; T&lt;/SPAN&gt;
        il.Emit(OpCodes.Castclass, &lt;SPAN class=kwrd&gt;typeof&lt;/SPAN&gt;(String));         &lt;SPAN class=rem&gt;// -&amp;gt; T&lt;/SPAN&gt;
        il.Emit(OpCodes.Ldc_I4, 1);                         &lt;SPAN class=rem&gt;// -&amp;gt; T, I4&lt;/SPAN&gt;
        il.Emit(OpCodes.Newarr, &lt;SPAN class=kwrd&gt;typeof&lt;/SPAN&gt;(Char));              &lt;SPAN class=rem&gt;// -&amp;gt; T&lt;/SPAN&gt;
        il.Emit(OpCodes.Dup);                               &lt;SPAN class=rem&gt;// -&amp;gt; T, T&lt;/SPAN&gt;
        il.Emit(OpCodes.Ldc_I4, 0);                         &lt;SPAN class=rem&gt;// -&amp;gt; T, T, I4&lt;/SPAN&gt;
        il.Emit(OpCodes.Ldc_I4, 0x3b);                      &lt;SPAN class=rem&gt;// -&amp;gt; T, T, I4, I4&lt;/SPAN&gt;
        il.Emit(OpCodes.Stelem_I2);                         &lt;SPAN class=rem&gt;// -&amp;gt; T&lt;/SPAN&gt;
        il.Emit(OpCodes.Ldc_I4, 1);                         &lt;SPAN class=rem&gt;// -&amp;gt; T, I4&lt;/SPAN&gt;
        il.EmitCall(OpCodes.Callvirt, splitMethod, &lt;SPAN class=kwrd&gt;null&lt;/SPAN&gt;);   &lt;SPAN class=rem&gt;// -&amp;gt; T&lt;/SPAN&gt;
        il.Emit(OpCodes.Stloc, searchDirs);                 &lt;SPAN class=rem&gt;// -&amp;gt;&lt;/SPAN&gt;

        &lt;SPAN class=rem&gt;// int index = args.Name.IndexOf(',');&lt;/SPAN&gt;
        LocalBuilder index = il.DeclareLocal(&lt;SPAN class=kwrd&gt;typeof&lt;/SPAN&gt;(&lt;SPAN class=kwrd&gt;int&lt;/SPAN&gt;));
        
        il.Emit(OpCodes.Ldarg, 1);                          &lt;SPAN class=rem&gt;// -&amp;gt; T&lt;/SPAN&gt;
        il.EmitCall(OpCodes.Callvirt, getName, &lt;SPAN class=kwrd&gt;null&lt;/SPAN&gt;);       &lt;SPAN class=rem&gt;// -&amp;gt; T&lt;/SPAN&gt;
        il.Emit(OpCodes.Ldc_I4, &lt;SPAN class=str&gt;','&lt;/SPAN&gt;);                       &lt;SPAN class=rem&gt;// -&amp;gt; T, T&lt;/SPAN&gt;
        il.EmitCall(OpCodes.Callvirt, indexOf, &lt;SPAN class=kwrd&gt;null&lt;/SPAN&gt;);       &lt;SPAN class=rem&gt;// -&amp;gt; T&lt;/SPAN&gt;
        il.Emit(OpCodes.Stloc, index);                      &lt;SPAN class=rem&gt;// -&amp;gt; &lt;/SPAN&gt;

        &lt;SPAN class=rem&gt;// if (index == -1)&lt;/SPAN&gt;
        Label indexThen = il.DefineLabel();
        
        il.Emit(OpCodes.Ldloc, index);                      &lt;SPAN class=rem&gt;// -&amp;gt; T&lt;/SPAN&gt;
        il.Emit(OpCodes.Ldc_I4_M1);                         &lt;SPAN class=rem&gt;// -&amp;gt; T&lt;/SPAN&gt;
        il.Emit(OpCodes.Ceq);                               &lt;SPAN class=rem&gt;// -&amp;gt; T&lt;/SPAN&gt;
        il.Emit(OpCodes.Brfalse, indexThen);                &lt;SPAN class=rem&gt;// -&amp;gt;&lt;/SPAN&gt;

        &lt;SPAN class=rem&gt;// index = args.Name.Length;&lt;/SPAN&gt;
        il.Emit(OpCodes.Ldarg, 1);                          &lt;SPAN class=rem&gt;// -&amp;gt; T&lt;/SPAN&gt;
        il.EmitCall(OpCodes.Callvirt, getName, &lt;SPAN class=kwrd&gt;null&lt;/SPAN&gt;);       &lt;SPAN class=rem&gt;// -&amp;gt; T&lt;/SPAN&gt;
        il.EmitCall(OpCodes.Callvirt, getLength, &lt;SPAN class=kwrd&gt;null&lt;/SPAN&gt;);     &lt;SPAN class=rem&gt;// -&amp;gt; T&lt;/SPAN&gt;
        il.Emit(OpCodes.Stloc, index);                      &lt;SPAN class=rem&gt;// -&amp;gt;&lt;/SPAN&gt;

        il.MarkLabel(indexThen);

        &lt;SPAN class=rem&gt;// string name = args.Name.Substring(0, index);&lt;/SPAN&gt;
        LocalBuilder name = il.DeclareLocal(&lt;SPAN class=kwrd&gt;typeof&lt;/SPAN&gt;(&lt;SPAN class=kwrd&gt;string&lt;/SPAN&gt;));

        il.Emit(OpCodes.Ldarg, 1);                          &lt;SPAN class=rem&gt;// -&amp;gt; T&lt;/SPAN&gt;
        il.EmitCall(OpCodes.Callvirt, getName, &lt;SPAN class=kwrd&gt;null&lt;/SPAN&gt;);       &lt;SPAN class=rem&gt;// -&amp;gt; T&lt;/SPAN&gt;
        il.Emit(OpCodes.Ldc_I4, 0);                         &lt;SPAN class=rem&gt;// -&amp;gt; T, I4&lt;/SPAN&gt;
        il.Emit(OpCodes.Ldloc, index);                      &lt;SPAN class=rem&gt;// -&amp;gt; T, I4, T&lt;/SPAN&gt;
        il.EmitCall(OpCodes.Callvirt, substring, &lt;SPAN class=kwrd&gt;null&lt;/SPAN&gt;);     &lt;SPAN class=rem&gt;// -&amp;gt; T&lt;/SPAN&gt;
        il.Emit(OpCodes.Stloc, name);                       &lt;SPAN class=rem&gt;// -&amp;gt;&lt;/SPAN&gt;

        &lt;SPAN class=rem&gt;// for (int i = 0; ...) ...&lt;/SPAN&gt;
        LocalBuilder i = il.DeclareLocal(&lt;SPAN class=kwrd&gt;typeof&lt;/SPAN&gt;(Int32));
        Label loopStart = il.DefineLabel();
        Label loopEnd = il.DefineLabel();

        il.Emit(OpCodes.Ldc_I4, 0);                         &lt;SPAN class=rem&gt;// -&amp;gt; I4&lt;/SPAN&gt;
        il.Emit(OpCodes.Stloc, i);                          &lt;SPAN class=rem&gt;// -&amp;gt;&lt;/SPAN&gt;
        il.Emit(OpCodes.Ldloc, i);                          &lt;SPAN class=rem&gt;// -&amp;gt; I4&lt;/SPAN&gt;
        il.Emit(OpCodes.Br, loopEnd);                       &lt;SPAN class=rem&gt;// -&amp;gt;&lt;/SPAN&gt;

        &lt;SPAN class=rem&gt;// string assemblyPath = Path.Combine(searchDirs[i], name) + ".dll";&lt;/SPAN&gt;
        LocalBuilder assemblyPath = il.DeclareLocal(&lt;SPAN class=kwrd&gt;typeof&lt;/SPAN&gt;(&lt;SPAN class=kwrd&gt;string&lt;/SPAN&gt;));
        Label ifEnd = il.DefineLabel();

        il.MarkLabel(loopStart);
        il.Emit(OpCodes.Ldloc, searchDirs);                 &lt;SPAN class=rem&gt;// -&amp;gt; T&lt;/SPAN&gt;
        il.Emit(OpCodes.Ldloc, i);                          &lt;SPAN class=rem&gt;// -&amp;gt; T, I4&lt;/SPAN&gt;
        il.Emit(OpCodes.Ldelem_Ref);                        &lt;SPAN class=rem&gt;// -&amp;gt; T&lt;/SPAN&gt;
        il.Emit(OpCodes.Ldloc, name);                       &lt;SPAN class=rem&gt;// -&amp;gt; T, T&lt;/SPAN&gt;
        il.EmitCall(OpCodes.Call, combine, &lt;SPAN class=kwrd&gt;null&lt;/SPAN&gt;);           &lt;SPAN class=rem&gt;// -&amp;gt; T &lt;/SPAN&gt;
        il.Emit(OpCodes.Ldstr, &lt;SPAN class=str&gt;".dll"&lt;/SPAN&gt;);                     &lt;SPAN class=rem&gt;// -&amp;gt; T, T&lt;/SPAN&gt;
        il.EmitCall(OpCodes.Callvirt, concat, &lt;SPAN class=kwrd&gt;null&lt;/SPAN&gt;);        &lt;SPAN class=rem&gt;// -&amp;gt; T&lt;/SPAN&gt;
        il.Emit(OpCodes.Stloc, assemblyPath);               &lt;SPAN class=rem&gt;// -&amp;gt;&lt;/SPAN&gt;

        &lt;SPAN class=rem&gt;// if (File.Exists(assemblyPath))&lt;/SPAN&gt;
        il.Emit(OpCodes.Ldloc, assemblyPath);               &lt;SPAN class=rem&gt;// -&amp;gt; T&lt;/SPAN&gt;
        il.EmitCall(OpCodes.Call, exists, &lt;SPAN class=kwrd&gt;null&lt;/SPAN&gt;);            &lt;SPAN class=rem&gt;// -&amp;gt; B&lt;/SPAN&gt;
        il.Emit(OpCodes.Brfalse, ifEnd);                    &lt;SPAN class=rem&gt;// -&amp;gt;&lt;/SPAN&gt;

        &lt;SPAN class=rem&gt;//    return Assembly.LoadFrom(assemblyPath);&lt;/SPAN&gt;
        il.Emit(OpCodes.Ldloc, assemblyPath);               &lt;SPAN class=rem&gt;// -&amp;gt; T&lt;/SPAN&gt;
        il.EmitCall(OpCodes.Callvirt, loadFrom, &lt;SPAN class=kwrd&gt;null&lt;/SPAN&gt;);      &lt;SPAN class=rem&gt;// -&amp;gt; T&lt;/SPAN&gt;
        il.Emit(OpCodes.Ret);                               &lt;SPAN class=rem&gt;// -&amp;gt; &lt;/SPAN&gt;

        &lt;SPAN class=rem&gt;// for (...; i &amp;lt; searchDirs.Length; i++)&lt;/SPAN&gt;
        il.MarkLabel(ifEnd);
        il.Emit(OpCodes.Ldloc, i);                          &lt;SPAN class=rem&gt;// -&amp;gt; I4&lt;/SPAN&gt;
        il.Emit(OpCodes.Ldc_I4, 1);                         &lt;SPAN class=rem&gt;// -&amp;gt; I4, I4&lt;/SPAN&gt;
        il.Emit(OpCodes.Add);                               &lt;SPAN class=rem&gt;// -&amp;gt; I4&lt;/SPAN&gt;
        il.Emit(OpCodes.Stloc, i);                          &lt;SPAN class=rem&gt;// -&amp;gt; &lt;/SPAN&gt;
        il.Emit(OpCodes.Ldloc, i);                          &lt;SPAN class=rem&gt;// -&amp;gt; I4&lt;/SPAN&gt;
        il.MarkLabel(loopEnd);
        il.Emit(OpCodes.Ldloc, searchDirs);                 &lt;SPAN class=rem&gt;// -&amp;gt; I4, T&lt;/SPAN&gt;
        il.Emit(OpCodes.Ldlen);                             &lt;SPAN class=rem&gt;// -&amp;gt; I4, I&lt;/SPAN&gt;
        il.Emit(OpCodes.Conv_I4);                           &lt;SPAN class=rem&gt;// -&amp;gt; I4, I4&lt;/SPAN&gt;
        il.Emit(OpCodes.Clt);                               &lt;SPAN class=rem&gt;// -&amp;gt; B&lt;/SPAN&gt;
        il.Emit(OpCodes.Brtrue, loopStart);                 &lt;SPAN class=rem&gt;// -&amp;gt;&lt;/SPAN&gt;

        &lt;SPAN class=rem&gt;// return null;&lt;/SPAN&gt;
        il.Emit(OpCodes.Ldnull);                            &lt;SPAN class=rem&gt;// -&amp;gt; T&lt;/SPAN&gt;
        il.Emit(OpCodes.Ret);                               &lt;SPAN class=rem&gt;// -&amp;gt;&lt;/SPAN&gt;
    }
}
&lt;/PRE&gt;
&lt;P&gt;Yikes! That almost 200 lines of code!&amp;nbsp; What this snippet shows you is that dynamic code generation in .NET is not cheap.&amp;nbsp; Let's touch on the key points.&lt;/P&gt;
&lt;P&gt;Stripping away the dynamic assembly generation, what this code wants to do is create a new appdomain and execute &lt;STRONG&gt;TestLoader&lt;/STRONG&gt; in it Remember this is the test loader that would normally fail to load the test assembly.&amp;nbsp; &lt;/P&gt;
&lt;P&gt;We are going to take the test assembly and the search path in to &lt;STRONG&gt;TestLoaderWrapper &lt;/STRONG&gt;and pass them to &lt;STRONG&gt;TestLoader.&amp;nbsp; &lt;/STRONG&gt;The test assembly is a command line argument, but the search path is passed through appdomain data, so we set that up with a call to &lt;STRONG&gt;SetData&lt;/STRONG&gt;.&lt;/P&gt;
&lt;P&gt;Now the heavy lifting.&amp;nbsp; We start by creating an &lt;STRONG&gt;AssemblyBuilder, ModuleBuilder, TypeBuilder, MethodBuilder&lt;/STRONG&gt; family of objects.&amp;nbsp; It's just a lot of paying attention to parameters.&lt;/P&gt;
&lt;P&gt;Then we call &lt;STRONG&gt;GenerateAssemblyResolveMethod&lt;/STRONG&gt; to build the IL for the method.&amp;nbsp;&amp;nbsp; I won't bore you with a tedious breakdown; the &lt;STRONG&gt;ILGenerator &lt;/STRONG&gt;methods are all very self explanatory and easy to follow.&amp;nbsp; I do have some tips to share on how I went about generating the code and typing it in.&lt;/P&gt;
&lt;P&gt;Firstly, &lt;A href="http://www.aisto.com/roeder/dotnet/"&gt;.NET Reflector&lt;/A&gt; is your friend.&amp;nbsp; The IL disassembly is a great way to get started with the correct IL.&amp;nbsp; Simply open up the version of &lt;STRONG&gt;TestLoader &lt;/STRONG&gt;that has &lt;STRONG&gt;ASSEMBLY_RESOLVE&lt;/STRONG&gt; defined and start cribbing.&amp;nbsp; &lt;/P&gt;
&lt;P&gt;What you are going to find really quickly however is that the C#, VB .NET or other compiler usually generate very verbose code, that seemingly takes a lot more IL instructions than necessary to get the job done.&amp;nbsp; What you have to remember is that IL is not meant to be executed directly, it's meant to be compiled (also known as the jitter).&amp;nbsp; The jitter will usually do a good job of removing much of the IL redundancy.&amp;nbsp; Actually, one technique for writing a jitter is to look for standard patterns of IL which can be optimized into native code sequence.&amp;nbsp; &lt;/P&gt;
&lt;P&gt;The other thing that the extra instructions help with is debugging, in particular the IL instruction boundaries where the IL stack hits zero entries are called sequence points and they typically map to a logical unit of source code that you can stop at in the debugger.&amp;nbsp; You can safely examine program variables at that point because, for example, the program will not be halfway through evaluating a source code expression.&amp;nbsp; &lt;/P&gt;
&lt;P&gt;All this is irrelevant to us though because unless you do some extra work to generate .pdb information for your dynamic assembly you want be able to see much in the debugger.&amp;nbsp; You can however insert a &lt;STRONG&gt;Break&lt;/STRONG&gt; opcode into it, turn off &lt;EM&gt;Just My Code &lt;/EM&gt;in VS and look at the native code that is generated for the method.&amp;nbsp; &lt;/P&gt;
&lt;P&gt;Getting back to the IL generation.&amp;nbsp; I took the .NET Reflector output as a starting point and began munging it into maintainable code.&amp;nbsp; As you can see grabbing methods and types to pass to IL instructions is just a question of calling Reflection API's.&amp;nbsp; Notice that I comment the current stack after each instruction executes.&amp;nbsp; &lt;STRONG&gt;T &lt;/STRONG&gt;is a metadata token, &lt;STRONG&gt;I4&lt;/STRONG&gt; means a 4 byte integer.&amp;nbsp; I break the IL generation down in to chunks where the IL stack returns to zero entries, for the reasons explained above and to help keep things readable.&amp;nbsp; &lt;/P&gt;
&lt;P&gt;What would really be awesome is if someone would write a .NET Reflector plug-in that would automatically generate Reflection Emit code for a method.&amp;nbsp; &lt;/P&gt;
&lt;P&gt;Almost there now.&amp;nbsp; We can specify a different directory for the generated assembly.&amp;nbsp; Don't know why, it just doesn't work, so we copy it next to the &lt;STRONG&gt;TestLoader&lt;/STRONG&gt; executable.&amp;nbsp; Why do we need to do this?&amp;nbsp; Because the appbase (the root directory where the CLR will probe for assemblies) is the directory of the entry assembly for the appdomain, which is different by default for &lt;STRONG&gt;TestLoader &lt;/STRONG&gt;than it is for &lt;STRONG&gt;TestLoaderWrapper &lt;/STRONG&gt;because they are in different directories.&lt;/P&gt;
&lt;P&gt;Then we create a delegate for the assembly resolve handler and attach it to the new &lt;STRONG&gt;AppDomain &lt;/STRONG&gt;object and we are done. &lt;/P&gt;
&lt;P&gt;I'll attach the source code for all this to the post for those who may stumble this way in search of help with this topic.&amp;nbsp; &lt;/P&gt;&lt;img src="http://lyon-smith.org/aggbug.aspx?PostID=178" width="1" height="1"&gt;</description><enclosure url="http://lyon-smith.org/blogs/code-o-rama/attachment/178.ashx" length="4972" type="application/x-zip-compressed" /><category domain="http://lyon-smith.org/blogs/code-o-rama/archive/tags/.net+2.0/default.aspx">.net 2.0</category><category domain="http://lyon-smith.org/blogs/code-o-rama/archive/tags/visual+studio/default.aspx">visual studio</category><category domain="http://lyon-smith.org/blogs/code-o-rama/archive/tags/probing/default.aspx">probing</category><category domain="http://lyon-smith.org/blogs/code-o-rama/archive/tags/assembly/default.aspx">assembly</category><category domain="http://lyon-smith.org/blogs/code-o-rama/archive/tags/windows/default.aspx">windows</category><category domain="http://lyon-smith.org/blogs/code-o-rama/archive/tags/c_2300_/default.aspx">c#</category><category domain="http://lyon-smith.org/blogs/code-o-rama/archive/tags/.net/default.aspx">.net</category><category domain="http://lyon-smith.org/blogs/code-o-rama/archive/tags/coding/default.aspx">coding</category><category domain="http://lyon-smith.org/blogs/code-o-rama/archive/tags/.net+3.5/default.aspx">.net 3.5</category></item><item><title>More .NET Custom Configuration Madness</title><link>http://lyon-smith.org/blogs/code-o-rama/archive/2007/12/09/more-net-custom-configuration-madness.aspx</link><pubDate>Mon, 10 Dec 2007 00:46:00 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:171</guid><dc:creator>john</dc:creator><slash:comments>0</slash:comments><description>&lt;P&gt;I have to blog about this before I do anything else.&amp;nbsp; I just found out that if you specify a &lt;STRONG&gt;configSection&lt;/STRONG&gt; in your &lt;STRONG&gt;.exe.config &lt;/STRONG&gt;file it &lt;EM&gt;must&lt;/EM&gt; come as the first element in the &lt;STRONG&gt;configuration &lt;/STRONG&gt;section!&amp;nbsp; I had done this:&lt;/P&gt;&lt;PRE class=csharpcode&gt;&lt;SPAN class=kwrd&gt;&amp;lt;?&lt;/SPAN&gt;&lt;SPAN class=html&gt;xml&lt;/SPAN&gt; &lt;SPAN class=attr&gt;version&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="1.0"&lt;/SPAN&gt; &lt;SPAN class=attr&gt;encoding&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="utf-8"&lt;/SPAN&gt; ?&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt; 
&lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;configuration&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
  &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;startup&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
    &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;supportedRuntime&lt;/SPAN&gt; &lt;SPAN class=attr&gt;version&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="v2.0.50727"&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;/&amp;gt;&lt;/SPAN&gt;
  &lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;startup&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
  &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;configSections&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
    &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;section&lt;/SPAN&gt; &lt;SPAN class=attr&gt;name&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="csr"&lt;/SPAN&gt; &lt;SPAN class=attr&gt;type&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;="Microsoft.Tools.CodeRunner.Tasks.CsrSection, Microsoft.Tools.CodeRunner, Version=2.0.0.0, Culture=neutral, PublicKeyToken=20af5850399c8643"&lt;/SPAN&gt; &lt;SPAN class=kwrd&gt;/&amp;gt;&lt;/SPAN&gt;
  &lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;configSections&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
  &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;csr&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
    &lt;SPAN class=kwrd&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN class=html&gt;settings&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
...
    &lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;settings&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
  &lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;csr&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;
&lt;SPAN class=kwrd&gt;&amp;lt;/&lt;/SPAN&gt;&lt;SPAN class=html&gt;configuration&lt;/SPAN&gt;&lt;SPAN class=kwrd&gt;&amp;gt;&lt;/SPAN&gt;&lt;/PRE&gt;
&lt;P&gt;Calling &lt;STRONG&gt;Configuration.GetSection("csr") &lt;/STRONG&gt;was resulting in a &lt;STRONG&gt;DefaultSection&lt;/STRONG&gt; type an not a &lt;STRONG&gt;CsrSection&lt;/STRONG&gt; type.&amp;nbsp;&amp;nbsp; Moving the &lt;STRONG&gt;startup&lt;/STRONG&gt; section after the &lt;STRONG&gt;configSection &lt;/STRONG&gt;fixed the problem.&amp;nbsp;&amp;nbsp; &lt;/P&gt;
&lt;P&gt;That's 5 stars on the suck scale in my opinion.&lt;/P&gt;&lt;img src="http://lyon-smith.org/aggbug.aspx?PostID=171" width="1" height="1"&gt;</description><category domain="http://lyon-smith.org/blogs/code-o-rama/archive/tags/.net/default.aspx">.net</category><category domain="http://lyon-smith.org/blogs/code-o-rama/archive/tags/microsoft/default.aspx">microsoft</category><category domain="http://lyon-smith.org/blogs/code-o-rama/archive/tags/bugs/default.aspx">bugs</category><category domain="http://lyon-smith.org/blogs/code-o-rama/archive/tags/coding/default.aspx">coding</category></item><item><title>The Smarter Emergency Kit</title><link>http://lyon-smith.org/blogs/ktthp/archive/2007/10/30/the-smarter-emergency-kit.aspx</link><pubDate>Tue, 30 Oct 2007 20:47:42 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:167</guid><dc:creator>john</dc:creator><slash:comments>0</slash:comments><description>&lt;p&gt;&lt;a href="http://www.wired.com/wired/"&gt;Wired Magazine&lt;/a&gt; did an article on emergency readiness.&amp;nbsp; I could not for the life of me find it on their web site, so here's what they recommend:&lt;/p&gt; &lt;p&gt;&lt;strong&gt;The House Kit&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;&lt;em&gt;Sealed in plastic trash can or chest.&amp;nbsp; For use in catastrophic situations, like earthquake, fire, etc..&amp;nbsp; You should probably be able to get it into the back of your car.&lt;/em&gt;&lt;/p&gt; &lt;p&gt;A. &lt;em&gt;First aid kit.&amp;nbsp;&amp;nbsp; &lt;/em&gt;Bandages, alcohol, cotton balls, antidiarrheals, anti-inflammatories (ibuprofen), prescription meds.&lt;/p&gt; &lt;p&gt;B. &lt;em&gt;Clothes.&lt;/em&gt;&amp;nbsp; Full change, including warm outer layers (wool or synthetic) and sturdy shoes for each person under your roof.&lt;/p&gt; &lt;p&gt;C. &lt;em&gt;Plastic Sheeting.&amp;nbsp; &lt;/em&gt;Fiber reinforced, laminated Poly. film, 6mm.&lt;/p&gt; &lt;p&gt;D. &lt;em&gt;Zip Ties&lt;/em&gt;.&amp;nbsp; &lt;/p&gt; &lt;p&gt;E. &lt;em&gt;Water&lt;/em&gt;.&amp;nbsp; Gallon per person for 3 days.&amp;nbsp; 16 drops unscented bleach makes a gallon potable.&lt;/p&gt; &lt;p&gt;F. &lt;em&gt;Food.&lt;/em&gt;&amp;nbsp; Dehydrated soups, canned tuna and veggies, nuts and candy.&lt;/p&gt; &lt;p&gt;G. &lt;em&gt;Flashlight&lt;/em&gt;.&amp;nbsp; LED like &lt;a href="http://www.inovalight.com/x.html"&gt;Inova X5&lt;/a&gt;.&amp;nbsp; &lt;/p&gt; &lt;p&gt;H. &lt;em&gt;Protective wear.&lt;/em&gt;&amp;nbsp; Waterproof, cut resistant Kevlar gloves and N95 face masks.&lt;/p&gt; &lt;p&gt;I. &lt;em&gt;Tools.&lt;/em&gt;&amp;nbsp; Crowbar, adjustable wrench, screwdrivers, staple gun, rope.&lt;/p&gt; &lt;p&gt;J. &lt;em&gt;Matches.&lt;/em&gt; Waterproof, windproof in ziplock bag with dry tinder.&lt;/p&gt; &lt;p&gt;&lt;strong&gt;The Go Pack&lt;/strong&gt;&lt;/p&gt; &lt;p&gt;&lt;em&gt;Keep in backpack ready to go.&amp;nbsp; For use when you need to leave at a moments notice.&lt;/em&gt;&lt;/p&gt; &lt;p&gt;K. &lt;em&gt;Radio &amp;amp; cell phones.&amp;nbsp; &lt;/em&gt;Cheap tranny is fine, but &lt;a href="http://www.etoncorp.com/product_card/?p_ProductDbId=6269"&gt;Eton Grundig FR300&lt;/a&gt; is even better.&lt;/p&gt; &lt;p&gt;L. &lt;em&gt;Cash. &lt;/em&gt; $500 in small bills.&lt;/p&gt; &lt;p&gt;M. &lt;em&gt;Documents.&lt;/em&gt;&amp;nbsp; Home insurance, contact numbers, medical insurance card, passport, bank account numbers, photos, local map, spare keys.&amp;nbsp; &lt;/p&gt; &lt;p&gt;N. &lt;em&gt;Mylar space blanket&lt;/em&gt;.&amp;nbsp; &lt;/p&gt; &lt;p&gt;O. &lt;em&gt;Clothes, etc.. &lt;/em&gt;Hat, socks, toiletries.&lt;/p&gt; &lt;p&gt;P. &lt;em&gt;Food &amp;amp; water.&lt;/em&gt;&amp;nbsp; Sports and nutrition bars, nuts trail, mix &amp;amp; water.&lt;/p&gt; &lt;p&gt;Q. &lt;em&gt;Essential medicines.&lt;/em&gt;&amp;nbsp; Sunblock, ibuprofen, contact lens kit.&lt;/p&gt; &lt;p&gt;R. &lt;em&gt;Duct tape.&lt;/em&gt;&amp;nbsp; &lt;/p&gt; &lt;p&gt;S. &lt;em&gt;Signal device.&amp;nbsp; &lt;/em&gt;&lt;a href="https://www.greatlandlaser.com/index.php?productID=161"&gt;Greatland Laser's Rescue Laser&lt;/a&gt; and &lt;a href="http://www.fox40world.com/"&gt;Fox 40 whistle&lt;/a&gt;.&lt;/p&gt; &lt;p&gt;T. &lt;em&gt;Multitool.&lt;/em&gt;&amp;nbsp; Leatherman with can opener, knife blade, screwdrivers.&lt;/p&gt;&lt;img src="http://lyon-smith.org/aggbug.aspx?PostID=167" width="1" height="1"&gt;</description><category domain="http://lyon-smith.org/blogs/ktthp/archive/tags/home/default.aspx">home</category><category domain="http://lyon-smith.org/blogs/ktthp/archive/tags/life/default.aspx">life</category><category domain="http://lyon-smith.org/blogs/ktthp/archive/tags/environment/default.aspx">environment</category></item><item><title>Top 25 Greatest Science Books of All Time</title><link>http://lyon-smith.org/blogs/ktthp/archive/2007/10/30/top-25-greatest-science-books-of-all-time.aspx</link><pubDate>Tue, 30 Oct 2007 16:57:16 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:166</guid><dc:creator>john</dc:creator><slash:comments>0</slash:comments><description>&lt;p&gt;In December 2006 &lt;a href="http://discovermagazine.com/"&gt;Discover Magazine&lt;/a&gt; did an article on the 25 greatest science books of all time.&amp;nbsp; You can find them &lt;a href="http://discovermagazine.com/2006/dec/25-greatest-science-books/"&gt;here&lt;/a&gt;.&amp;nbsp;&amp;nbsp; The list was interesting, but let's be honest how many of us have actually read &lt;em&gt;anything &lt;/em&gt;by Charles Darwin?&amp;nbsp; The &lt;a href="http://discovermagazine.com/2006/dec/poll-greatest-science-books-results/?searchterm=greatest%20science%20books"&gt;reader's response&lt;/a&gt; was rather weak too.&amp;nbsp; Personally I've only read about half a dozen of the books on the list.&amp;nbsp; Perhaps there's an opportunity for someone to write a synopsis of all the books in one single easily digestible paperback.&lt;/p&gt; &lt;p&gt;&lt;em&gt;I wrote this entry because I've been carrying around the torn out pages of the article in my notebook since last December.&amp;nbsp; How sad is that.&lt;/em&gt;&lt;/p&gt;&lt;img src="http://lyon-smith.org/aggbug.aspx?PostID=166" width="1" height="1"&gt;</description><category domain="http://lyon-smith.org/blogs/ktthp/archive/tags/life/default.aspx">life</category><category domain="http://lyon-smith.org/blogs/ktthp/archive/tags/science/default.aspx">science</category></item><item><title>Arrays in PowerShell</title><link>http://lyon-smith.org/blogs/code-o-rama/archive/2007/10/23/arrays-in-powershell.aspx</link><pubDate>Tue, 23 Oct 2007 15:39:00 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:165</guid><dc:creator>john</dc:creator><slash:comments>0</slash:comments><description>&lt;p&gt;While I'm waiting for some files to copy around I thought I'd record my recent PowerShell learnin'.&lt;/p&gt; &lt;p&gt;Somtimes a command, like &lt;strong&gt;Get-ChildItem&lt;/strong&gt; can return either an array of results or just a single one.&amp;nbsp; You can use the &lt;strong&gt;@&lt;/strong&gt; symbol to cast the result into an array, so:&lt;/p&gt;&lt;pre class="csharpcode"&gt;(gci -i *.txt).Count&lt;/pre&gt;
&lt;p&gt;Sometimes returns nothing, whereas:&lt;/p&gt;&lt;pre class="csharpcode"&gt;@(gci -i *.txt).Count&lt;/pre&gt;
&lt;p&gt;Always returns the count of *.txt files.&lt;/p&gt;
&lt;p&gt;Second thing.&amp;nbsp; The &lt;strong&gt;.. &lt;/strong&gt;is the syntax for ranges.&amp;nbsp; So &lt;strong&gt;1..10&lt;/strong&gt; is expanded into an array of the numbers 1 thru 10.&amp;nbsp;&amp;nbsp; Turns out you can also use arrays as indexes!&amp;nbsp; Each item in the index array is used to index an item in the data array, thus returning a new array.&lt;/p&gt;
&lt;p&gt;There's an example in the help that is confusing at first sight:&lt;/p&gt;&lt;pre class="csharpcode"&gt;$a[0..-2]&lt;/pre&gt;
&lt;p&gt;Returns the first, last and second to last elements in the array in that order.&amp;nbsp; Why? Because the range is expanded into a list, equivalent to:&lt;/p&gt;&lt;pre class="csharpcode"&gt;$a[-2,-1,0]&lt;/pre&gt;
&lt;p&gt;Make sense?&amp;nbsp; &lt;/p&gt;
&lt;p&gt;If you write blogs with code in and you are using LiveWriter grab the &lt;a href="http://gallery.live.com/liveItemDetail.aspx?li=1f57bd9b-a692-4593-9e9e-e2962d9c0eee&amp;amp;bt=9&amp;amp;pl=8&amp;amp;wa=wsignin1.0" target="_blank"&gt;Insert Code for Windows Live Writer plug-in&lt;/a&gt;.&amp;nbsp; It's got some flaws, but it's a huge time saver.&lt;/p&gt;&lt;img src="http://lyon-smith.org/aggbug.aspx?PostID=165" width="1" height="1"&gt;</description><category domain="http://lyon-smith.org/blogs/code-o-rama/archive/tags/windows/default.aspx">windows</category><category domain="http://lyon-smith.org/blogs/code-o-rama/archive/tags/powershell/default.aspx">powershell</category></item><item><title>Line Count with PowerShell</title><link>http://lyon-smith.org/blogs/code-o-rama/archive/2007/10/22/line-count-with-powershell.aspx</link><pubDate>Tue, 23 Oct 2007 03:35:00 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:164</guid><dc:creator>john</dc:creator><slash:comments>0</slash:comments><description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Starting to get the hang of PowerShell.&amp;nbsp; Today I wanted to quickly count the number of lines in some source code.&amp;nbsp;&amp;nbsp; There's a &lt;A href="http://timheuer.com/blog/archive/2007/04/23/14050.aspx"&gt;simple implementation&lt;/A&gt; and then there's a &lt;A href="http://www.leeholmes.com/blog/CountingLinesOfSourceCodeInPowerShell.aspx"&gt;better one&lt;/A&gt;.&amp;nbsp; In the end I settled on:&lt;/P&gt;&lt;PRE class=csharpcode style="WIDTH:439px;HEIGHT:42px;"&gt;$count=0;gci . -i *.cs,*.cpp,*.h -r | %{$count += [System.IO.File]::ReadAllLines($_.FullName).Count};$count&lt;/PRE&gt;
&lt;P&gt;Which is quick to type and fast enough for me, although as the links show you can butter it up and put it in a &lt;STRONG&gt;.ps1&lt;/STRONG&gt; file if you want too.&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;Puzzle Time!&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;Here's a little PowerShell test that I have to admit I had to get some help with.&amp;nbsp; Why does:&lt;/P&gt;&lt;PRE class=csharpcode&gt;1,2,3 | %{$_}&lt;/PRE&gt;
&lt;P&gt;Produce the output:&lt;/P&gt;&lt;PRE class=csharpcode&gt;1
2
3&lt;/PRE&gt;
&lt;P&gt;But this produces nothing:&lt;/P&gt;&lt;PRE class=csharpcode&gt;$code={%{$_}}
1,2,3 | &amp;amp;$code&lt;/PRE&gt;
&lt;P&gt;Remember, &lt;STRONG&gt;&amp;amp;&lt;/STRONG&gt; executes a script block and &lt;STRONG&gt;%&lt;/STRONG&gt; is just an alias for &lt;STRONG&gt;Foreach-Object&lt;/STRONG&gt;. &lt;/P&gt;
&lt;P&gt;Want the answer?&lt;/P&gt;
&lt;P&gt;It's a question of scope.&amp;nbsp; In the second example &lt;STRONG&gt;&amp;amp;$code&lt;/STRONG&gt; is equivalent to &lt;STRONG&gt;&amp;amp;{%{$_}}&lt;/STRONG&gt;.&amp;nbsp; The extra &lt;STRONG&gt;{}&lt;/STRONG&gt;'s puts $_ in a different &lt;A href="http://blogs.msdn.com/powershell/archive/2007/04/14/controlling-the-scope-of-variables.aspx"&gt;script variable scope&lt;/A&gt;, one in which it has not been initialized.&amp;nbsp; To get things working again, you need to reattach it to the pipeline input, like so:&lt;/P&gt;&lt;PRE class=csharpcode&gt;$code={$input | %{$_}}
1,2,3 | &amp;amp;$code
&lt;/PRE&gt;&lt;img src="http://lyon-smith.org/aggbug.aspx?PostID=164" width="1" height="1"&gt;</description><category domain="http://lyon-smith.org/blogs/code-o-rama/archive/tags/windows/default.aspx">windows</category><category domain="http://lyon-smith.org/blogs/code-o-rama/archive/tags/powershell/default.aspx">powershell</category></item><item><title>More PowerShell Fun</title><link>http://lyon-smith.org/blogs/code-o-rama/archive/2007/10/17/more-powershell-fun.aspx</link><pubDate>Wed, 17 Oct 2007 18:33:00 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:163</guid><dc:creator>john</dc:creator><slash:comments>0</slash:comments><description>&lt;P&gt;Still struggling to gain traction with PowerShell.&amp;nbsp; I've stopped myself running the CMD prompt by default, and I've installed it on all my test VPC machines.&lt;/P&gt;
&lt;P&gt;Firstly, I recommend you download the &lt;A href="http://www.microsoft.com/downloads/details.aspx?FamilyId=3B3F7CE4-43EA-4A21-90CC-966A7FC6C6E8&amp;amp;displaylang=en" target=_blank&gt;Windows PowerShell Graphical Help File&lt;/A&gt;.&amp;nbsp; It's an old school .chm file, &lt;EM&gt;but you can search it.&amp;nbsp; &lt;/EM&gt;Don't underestimate how useful this is when learning new stuff.&lt;/P&gt;
&lt;P&gt;Also, I totally hate the magic behind &lt;STRONG&gt;env:&lt;/STRONG&gt; prefixed variables.&amp;nbsp; They are basically a secret back door to the processes environment variables.&amp;nbsp; It seems that the the processes environment variables are mirrored into variables starting with &lt;STRONG&gt;$env:&amp;nbsp; &lt;/STRONG&gt;So &lt;STRONG&gt;$env:path&lt;/STRONG&gt; gets you the PATH and &lt;STRONG&gt;$env:pathext&lt;/STRONG&gt; gets you PATHEXT.&amp;nbsp; This is not documented anywhere that I can find.&amp;nbsp;&amp;nbsp; What's important is that these environment variables are still important in many cases.&amp;nbsp; So &lt;STRONG&gt;$env.path&lt;/STRONG&gt; is still the search path for programs, and &lt;STRONG&gt;$env.pathext&lt;/STRONG&gt; is still appended to any program you type without an extension.&lt;/P&gt;
&lt;P&gt;&lt;A href="http://www.amazon.com/Windows-PowerShell-Unleashed-Tyson-Kopczynski/dp/0672329530/ref=si3_rdr_bb_product/102-0153047-6235371" target=_blank&gt;&lt;IMG style="WIDTH:125px;HEIGHT:125px;" height=125 src="http://ecx.images-amazon.com/images/I/51aple8yQ3L._BO2,204,203,200_PIsitb-dp-500-arrow,TopRight,45,-64_OU01_AA240_SH20_.jpg" width=125 align=left border=0&gt;&lt;/A&gt;I grabbed a copy of &lt;A class="" href="http://www.amazon.com/Windows-PowerShell-Unleashed-Tyson-Kopczynski/dp/0672329530/ref=si3_rdr_bb_product/102-0153047-6235371"&gt;Windows PowerShell Unleashed&lt;/A&gt; from the Microsoft library.&amp;nbsp; It's not a bad introduction.&amp;nbsp; I don't think it's much of a long term reference book though.&amp;nbsp; There are too many important details missing (like the one above).&lt;/P&gt;&lt;img src="http://lyon-smith.org/aggbug.aspx?PostID=163" width="1" height="1"&gt;</description><category domain="http://lyon-smith.org/blogs/code-o-rama/archive/tags/windows/default.aspx">windows</category><category domain="http://lyon-smith.org/blogs/code-o-rama/archive/tags/powershell/default.aspx">powershell</category></item><item><title>Changing the Desktop Wallpaper Programmatically on Windows</title><link>http://lyon-smith.org/blogs/code-o-rama/archive/2007/10/12/changing-the-desktop-wallpaper-programmatically-on-windows.aspx</link><pubDate>Fri, 12 Oct 2007 20:39:23 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:162</guid><dc:creator>john</dc:creator><slash:comments>0</slash:comments><description>&lt;p&gt;My friend Scott asked me the other day how he might go about changing the desktop wallpaper programmatically.&amp;nbsp; It's one of those things that is still buried in the native Windows Win32 API.&amp;nbsp; The call you need is &lt;a href="http://msdn2.microsoft.com/en-us/library/ms724947.aspx"&gt;SystemParametersInfo&lt;/a&gt; and the action you need is SPI_SETDESKWALLPAPER.&lt;/p&gt; &lt;p&gt;Scott pointed out that this only takes a bitmap.&amp;nbsp; On Windows XP, if you set the desktop wallpaper to a JPEG under Control Panel it actually converts it to a bitmap and then makes this call.&amp;nbsp; With Windows Vista, the JPEG can be set directly.&amp;nbsp; &lt;/p&gt;&lt;img src="http://lyon-smith.org/aggbug.aspx?PostID=162" width="1" height="1"&gt;</description><category domain="http://lyon-smith.org/blogs/code-o-rama/archive/tags/windows/default.aspx">windows</category><category domain="http://lyon-smith.org/blogs/code-o-rama/archive/tags/tweaks/default.aspx">tweaks</category><category domain="http://lyon-smith.org/blogs/code-o-rama/archive/tags/vista/default.aspx">vista</category><category domain="http://lyon-smith.org/blogs/code-o-rama/archive/tags/xp/default.aspx">xp</category></item><item><title>The Singleton Pattern in .NET and C#</title><link>http://lyon-smith.org/blogs/code-o-rama/archive/2007/10/11/the-singleton-pattern-in-net-and-c.aspx</link><pubDate>Thu, 11 Oct 2007 16:18:18 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:161</guid><dc:creator>john</dc:creator><slash:comments>0</slash:comments><description>&lt;p&gt;I just got bitten by a static initialization problem - again.&amp;nbsp; There are two things you've got to be careful of in .NET when using statics (i) threading issues and (ii) initialization ordering issues.&amp;nbsp; I'm not going to go into a great long discussion about the issues as it's been covered really well in other places.&amp;nbsp; The rules are simple, but there are a couple of tricky wrinkles, and it's one of those areas that you don't code to all the time, so by the time you need to know the "&lt;em&gt;really important thing"&lt;/em&gt; you've forgotten it.&amp;nbsp; Anyway, I found &lt;a href="http://www.yoda.arachsys.com/csharp/singleton.html"&gt;Implementing the Singleton Pattern in C#&lt;/a&gt; to be the most helpful memory jogger.&amp;nbsp; Bart de Smet's blog shows how to do &lt;a href="http://community.bartdesmet.net/blogs/bart/archive/2006/10/30/Answers-to-C_2300_-Quiz-_2D00_-Static-constructors-and-type-initialization-.aspx"&gt;deterministic initialization order&lt;/a&gt; by using the &lt;a href="http://msdn2.microsoft.com/en-us/library/system.runtime.compilerservices.runtimehelpers.runclassconstructor.aspx" target="_blank"&gt;RuntimeHelpers.RunClassConstructor&lt;/a&gt; method.&lt;/p&gt;&lt;img src="http://lyon-smith.org/aggbug.aspx?PostID=161" width="1" height="1"&gt;</description></item><item><title>Changing the Windows Log On Keyboard Layout to Dvorak</title><link>http://lyon-smith.org/blogs/code-o-rama/archive/2007/10/03/changing-the-log-on-keyboard-layout-to-dvorak.aspx</link><pubDate>Thu, 04 Oct 2007 01:15:23 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:160</guid><dc:creator>john</dc:creator><slash:comments>0</slash:comments><description>&lt;p&gt;If you found this entry, you are either a Dvorak keyboard typist searching for help&amp;nbsp;or you are a strange individual who reads my blog but never leaves a comment.&lt;/p&gt; &lt;p&gt;If you are the former then the link you are looking for is to this Microsoft Help &amp;amp; Support Article stupidly entitled &lt;a href="http://support.microsoft.com/kb/128799"&gt;Unable to Log On after Changing Keyboard Layout&lt;/a&gt;&amp;nbsp;which will tell you how to change the default users logon keyboard layout to Dvorak.&lt;/p&gt;&lt;img src="http://lyon-smith.org/aggbug.aspx?PostID=160" width="1" height="1"&gt;</description><category domain="http://lyon-smith.org/blogs/code-o-rama/archive/tags/windows/default.aspx">windows</category><category domain="http://lyon-smith.org/blogs/code-o-rama/archive/tags/dvorak/default.aspx">dvorak</category><category domain="http://lyon-smith.org/blogs/code-o-rama/archive/tags/tips/default.aspx">tips</category></item><item><title>Halo 3 Videos</title><link>http://lyon-smith.org/blogs/ktthp/archive/2007/10/03/halo-3-videos.aspx</link><pubDate>Wed, 03 Oct 2007 23:13:18 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:159</guid><dc:creator>john</dc:creator><slash:comments>0</slash:comments><description>&lt;p&gt;Amusing Halo 3 videos are starting to permeate the web.&amp;nbsp; If you are not a video gamer read no further.&amp;nbsp; If you are and you aren't playing Halo 3 ... ARE YOU CRAZY!&amp;nbsp; Go buy a copy.&amp;nbsp; A cool feature is that you can take video of a game and publish export it to the web.&amp;nbsp; Check out&amp;nbsp;&lt;a href="http://gameroom.mlgpro.com/view/rhojIAED55g.html"&gt;My WiLL Be Done&lt;/a&gt;&amp;nbsp;for an amazing lucky shot.&amp;nbsp; It almost looks like a homing missile.&lt;/p&gt;&lt;img src="http://lyon-smith.org/aggbug.aspx?PostID=159" width="1" height="1"&gt;</description><category domain="http://lyon-smith.org/blogs/ktthp/archive/tags/xbox+360/default.aspx">xbox 360</category><category domain="http://lyon-smith.org/blogs/ktthp/archive/tags/humor/default.aspx">humor</category></item><item><title>Adventures with PowerShell</title><link>http://lyon-smith.org/blogs/code-o-rama/archive/2007/09/26/adventures-with-powershell.aspx</link><pubDate>Wed, 26 Sep 2007 21:44:54 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:158</guid><dc:creator>john</dc:creator><slash:comments>0</slash:comments><description>&lt;p&gt;I've held off moving to Windows PowerShell.&amp;nbsp; The&amp;nbsp;reason is that&amp;nbsp;I came up with a solution for running C#&amp;nbsp;source directly from the&amp;nbsp;command line as script a few years&amp;nbsp;ago using &lt;a href="http://www.codeplex.com/CodeRunner"&gt;CodeRunner .NET&lt;/a&gt;, and I've haven't had a pressing need for more functionality.&amp;nbsp; &lt;/p&gt; &lt;p&gt;But I decided that the time has come to say goodbye to the DOS prompt.&amp;nbsp; I'm going to bring the CodeRunner along too.&amp;nbsp; Perhaps as a &lt;a href="http://msdn2.microsoft.com/en-us/library/ms714657.aspx"&gt;Cmdlet&lt;/a&gt;.&amp;nbsp; This blog is a collection of useful links that I have found so far.&lt;/p&gt; &lt;p&gt;First stop.&amp;nbsp; The &lt;a href="http://www.microsoft.com/windowsserver2003/technologies/management/powershell/default.mspx"&gt;official PowerShell web site&lt;/a&gt;.&amp;nbsp; All the links to the latest downloads, etc..&amp;nbsp; &lt;/p&gt; &lt;p&gt;The &lt;a href="http://www.microsoft.com/technet/scriptcenter/topics/winpsh/manual/default.mspx"&gt;PowerShell Owners Manual&lt;/a&gt; looks promising, but not yet deliver the goods.&lt;/p&gt; &lt;p&gt;This Channel 9 Wiki has a great &lt;a href="http://channel9.msdn.com/wiki/default.aspx/Channel9.WindowsPowerShellQuickStart"&gt;PowerShell quick start page&lt;/a&gt;.&lt;/p&gt; &lt;p&gt;First thing I wanted to do was &lt;a href="http://www.exchangeninjas.com/ChangePrompt"&gt;change the PowerShell prompt&lt;/a&gt;, and&amp;nbsp;I couldn't figure how.&amp;nbsp;&lt;/p&gt; &lt;p&gt;And of course, last but not least the &lt;a href="http://msdn2.microsoft.com/en-us/library/aa139691.aspx"&gt;MSDN PowerShell documentation&lt;/a&gt;.&lt;/p&gt;&lt;img src="http://lyon-smith.org/aggbug.aspx?PostID=158" width="1" height="1"&gt;</description><category domain="http://lyon-smith.org/blogs/code-o-rama/archive/tags/windows/default.aspx">windows</category><category domain="http://lyon-smith.org/blogs/code-o-rama/archive/tags/powershell/default.aspx">powershell</category></item><item><title>Dr. Who Theme Music</title><link>http://lyon-smith.org/blogs/ktthp/archive/2007/09/04/dr-who-theme-music.aspx</link><pubDate>Tue, 04 Sep 2007 22:17:57 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:157</guid><dc:creator>john</dc:creator><slash:comments>0</slash:comments><description>&lt;p&gt;I'm a big fan of &lt;a href="http://www.bbc.co.uk/doctorwho/"&gt;Dr. Who&lt;/a&gt;.&amp;nbsp; I'm not going to apologize.&amp;nbsp; It's campy British sci-fi, with low budgets, cheesy plots and terrible acting, but I love it.&amp;nbsp; The current series, with David Tennant,&amp;nbsp;is the best ever.&amp;nbsp; In my area it's being shown on CBC.&amp;nbsp; Catch it if you can.&lt;/p&gt; &lt;p&gt;I stumbled across this YouTube vid on a &lt;a href="http://www.youtube.com/watch?v=zDxFqw36KQ0"&gt;re-making of the classic Dr. Who theme tune back in the 80's&lt;/a&gt;.&amp;nbsp; This was a time, as my friend Lucien informed me the other day, when there was no digital music generation. Everything was analog, and being able to tweak the dials and sliders well was as much playing the instrument as hitting the keyboard.&lt;/p&gt;&lt;img src="http://lyon-smith.org/aggbug.aspx?PostID=157" width="1" height="1"&gt;</description><category domain="http://lyon-smith.org/blogs/ktthp/archive/tags/music/default.aspx">music</category><category domain="http://lyon-smith.org/blogs/ktthp/archive/tags/viral+video/default.aspx">viral video</category></item><item><title>What I did on my vacation (part 1)</title><link>http://lyon-smith.org/blogs/ktthp/archive/2007/09/04/what-i-did-on-my-vacation-part-1.aspx</link><pubDate>Tue, 04 Sep 2007 18:04:00 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:155</guid><dc:creator>john</dc:creator><slash:comments>0</slash:comments><description>&lt;P&gt;&lt;A href="http://lyon-smith.org/photos/ktthp/images/156/original.aspx" target=_blank&gt;&lt;IMG hspace=10 src="http://lyon-smith.org/photos/ktthp/images/156/secondarythumb.aspx" align=left border=0&gt;&lt;/A&gt;I just got back from my summer vacation.&amp;nbsp; We spent a week in Puerto Rico (more on that in another blog) and a week at home.&amp;nbsp; I always like to have a project that has nothing to do with computers, so I built a garden shed.&amp;nbsp; I didn't use a plan or kit or anything, just scribbled a design on a sheet of paper, bought some wood and went for it.&amp;nbsp; I was really pleased with how it came out.&amp;nbsp; This was my first experience of putting gutters up, and it wasn't hard at all.&amp;nbsp; What was hard was building the shed up against the house.&amp;nbsp; I had to build the frame and the back wall with it pulled out from the house, and the push it back in before putting the roof on and the whole thing got to heavy.&amp;nbsp; It's going to fun when it comes time to paint the house!&amp;nbsp; The gutter was a safety precaution because I didn't want the water from the roof pooling next to the foundation of the house.&amp;nbsp; I bought all the materials from Home Depot, and looking at my receipts it looks like I spent about $400 to build it.&amp;nbsp; That's certainly cheaper than the $1000+ shed kits that you can buy, plus I got exactly the shed that I wanted.&lt;/P&gt;&lt;img src="http://lyon-smith.org/aggbug.aspx?PostID=155" width="1" height="1"&gt;</description><category domain="http://lyon-smith.org/blogs/ktthp/archive/tags/home/default.aspx">home</category><category domain="http://lyon-smith.org/blogs/ktthp/archive/tags/life/default.aspx">life</category><category domain="http://lyon-smith.org/blogs/ktthp/archive/tags/home+improvement/default.aspx">home improvement</category><category domain="http://lyon-smith.org/blogs/ktthp/archive/tags/hardware/default.aspx">hardware</category><category domain="http://lyon-smith.org/blogs/ktthp/archive/tags/outdoor/default.aspx">outdoor</category></item><item><title>The Fastest Stupid Car Ever</title><link>http://lyon-smith.org/blogs/ktthp/archive/2007/08/31/top-gear-does-red-vs-blue.aspx</link><pubDate>Sat, 01 Sep 2007 04:52:29 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:154</guid><dc:creator>john</dc:creator><slash:comments>0</slash:comments><description>&lt;p&gt;Sorry, I'm on a bit of a Top Gear binge at the moment.&amp;nbsp; Watch &lt;a href="http://www.youtube.com/watch?v=eCbLn3_ilic&amp;amp;NR=1"&gt;the fastest stupid car ever&lt;/a&gt; -&amp;nbsp; I laughed so hard I was crying.&lt;/p&gt;&lt;img src="http://lyon-smith.org/aggbug.aspx?PostID=154" width="1" height="1"&gt;</description><category domain="http://lyon-smith.org/blogs/ktthp/archive/tags/funny/default.aspx">funny</category><category domain="http://lyon-smith.org/blogs/ktthp/archive/tags/viral+video/default.aspx">viral video</category></item><item><title>Second Largest Underground Car Park</title><link>http://lyon-smith.org/blogs/ktthp/archive/2007/08/11/second-largest-underground-car-park.aspx</link><pubDate>Sat, 11 Aug 2007 20:48:39 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:153</guid><dc:creator>john</dc:creator><slash:comments>0</slash:comments><description>&lt;p&gt;My company (Microsoft) is currently digging a really large hole just on the other side of the freeway from my office.&amp;nbsp; It's reportedly going to be the second largest underground car park in the western hemisphere.&amp;nbsp; &lt;a href="http://www.king5.com/sharedcontent/video/makeASX.php?title=www.king5.com/ki_062107microsoftdirt_feldman_5pm.wmv"&gt;Here's a recent TV spot about it&lt;/a&gt;.&amp;nbsp; Parking can be a really big problem around Microsoft.&amp;nbsp; Kudos to the company for spending the huge amount of money to do this just so that employees can have some open space to hang out in.&lt;/p&gt;&lt;img src="http://lyon-smith.org/aggbug.aspx?PostID=153" width="1" height="1"&gt;</description><category domain="http://lyon-smith.org/blogs/ktthp/archive/tags/work/default.aspx">work</category><category domain="http://lyon-smith.org/blogs/ktthp/archive/tags/viral+video/default.aspx">viral video</category><category domain="http://lyon-smith.org/blogs/ktthp/archive/tags/microsoft/default.aspx">microsoft</category></item><item><title>3 Really Great Top Gear Episodes</title><link>http://lyon-smith.org/blogs/ktthp/archive/2007/08/06/3-really-great-top-gear-episodes.aspx</link><pubDate>Mon, 06 Aug 2007 19:37:36 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:152</guid><dc:creator>john</dc:creator><slash:comments>0</slash:comments><description>&lt;p&gt;I watched three brilliant &lt;a href="http://www.bbc.co.uk/topgear/"&gt;Top Gear&lt;/a&gt; episodes this weekend on You Tube.&amp;nbsp;&amp;nbsp; &lt;/p&gt; &lt;p&gt;The first was a review of the &lt;a href="http://www.arielatom.com/"&gt;Ariel Atom&lt;/a&gt;.&amp;nbsp;&amp;nbsp; &lt;a href="http://www.youtube.com/watch?v=WaWoo82zNUA"&gt;Watch Jeremy's face deform under the sub-three second acceleration&lt;/a&gt;.&amp;nbsp; His comments about middle aged men on motorcycles cracked me up.&lt;/p&gt; &lt;p&gt;The second was the review of the Ferrari F430.&amp;nbsp; &lt;a href="http://www.youtube.com/watch?v=HN9xlMgAPuU"&gt;What a beautiful piece of machinery&lt;/a&gt;.&lt;/p&gt; &lt;p&gt;Finally there was the &lt;a href="http://www.youtube.com/watch?v=5lJwlUJU-f8"&gt;face off between a Mitsubishi Evo VIII and a Lamborghini Mercielago&lt;/a&gt;.&amp;nbsp; That one is for Rich.&lt;/p&gt;&lt;img src="http://lyon-smith.org/aggbug.aspx?PostID=152" width="1" height="1"&gt;</description><category domain="http://lyon-smith.org/blogs/ktthp/archive/tags/links/default.aspx">links</category><category domain="http://lyon-smith.org/blogs/ktthp/archive/tags/viral+video/default.aspx">viral video</category><category domain="http://lyon-smith.org/blogs/ktthp/archive/tags/top+gear/default.aspx">top gear</category><category domain="http://lyon-smith.org/blogs/ktthp/archive/tags/cars/default.aspx">cars</category></item><item><title>Team System Web Access Power Tool Announced</title><link>http://lyon-smith.org/blogs/code-o-rama/archive/2007/07/30/team-system-web-access-power-tool-announced.aspx</link><pubDate>Mon, 30 Jul 2007 23:05:43 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:151</guid><dc:creator>john</dc:creator><slash:comments>0</slash:comments><description>&lt;p&gt;OK, in my opinion this is a bit more than a power tool - it's an entire product.&amp;nbsp; If you are using Team System you need to download and set up the &lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=2105C9EE-565E-47B9-A5AC-9A8FF8A07862&amp;amp;displaylang=en"&gt;Team System Web Access Power Toy&lt;/a&gt; that we just released.&amp;nbsp; Team System Web Access (formerly known as TeamPlain) is a Web interface to Visual Studio 2005 Team Foundation Server.&amp;nbsp; We are using it internally, and it's really sweet.&amp;nbsp; &lt;a href="http://blogs.msdn.com/bharry/archive/2007/07/30/team-system-web-access-power-tool-available.aspx"&gt;Read Brian Harry's comments about it&lt;/a&gt;.&lt;/p&gt;&lt;img src="http://lyon-smith.org/aggbug.aspx?PostID=151" width="1" height="1"&gt;</description><category domain="http://lyon-smith.org/blogs/code-o-rama/archive/tags/visual+studio/default.aspx">visual studio</category><category domain="http://lyon-smith.org/blogs/code-o-rama/archive/tags/microsoft/default.aspx">microsoft</category><category domain="http://lyon-smith.org/blogs/code-o-rama/archive/tags/team+system/default.aspx">team system</category></item><item><title>Getting Windows crash dumps</title><link>http://lyon-smith.org/blogs/code-o-rama/archive/2007/07/27/getting-windows-crash-dumps.aspx</link><pubDate>Fri, 27 Jul 2007 22:01:10 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:150</guid><dc:creator>john</dc:creator><slash:comments>0</slash:comments><description>&lt;p&gt;Every so often I need get a crash dump for a crashing native process, and I always forget where to find the tools.&amp;nbsp; The easiest to use is ADPlus which is part of the &lt;a href="http://www.microsoft.com/whdc/devtools/debugging/default.mspx"&gt;Debugging Tools for Windows&lt;/a&gt;.&amp;nbsp; The best write-up I've found on other alternatives and how to take crash dumps is &lt;a href="http://blogs.technet.com/askperf/archive/2007/06/15/capturing-application-crash-dumps.aspx"&gt;from the ASKPERF blog&lt;/a&gt;.&lt;/p&gt;&lt;img src="http://lyon-smith.org/aggbug.aspx?PostID=150" width="1" height="1"&gt;</description><category domain="http://lyon-smith.org/blogs/code-o-rama/archive/tags/windows/default.aspx">windows</category><category domain="http://lyon-smith.org/blogs/code-o-rama/archive/tags/debugging/default.aspx">debugging</category></item><item><title>Chris Sharma Rules!</title><link>http://lyon-smith.org/blogs/ktthp/archive/2007/07/24/chris-sharma-rules.aspx</link><pubDate>Wed, 25 Jul 2007 03:38:43 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:149</guid><dc:creator>john</dc:creator><slash:comments>0</slash:comments><description>&lt;p&gt;Chris Sharma is certainly an amazing rock climber.&amp;nbsp; He isn't massive or particularly graceful, but he has amazing determination and arm strength.&amp;nbsp; Here is a selection of my favorite videos featuring him on YouTube.&lt;/p&gt; &lt;ul&gt; &lt;li&gt;&lt;a href="http://youtube.com/watch?v=UlcQ3mxlNfs"&gt;Dreamcatcher&lt;/a&gt;.&amp;nbsp; &lt;em&gt;A beautiful traverse line on an overhanging lip with the crux right at the end.&lt;/em&gt;  &lt;li&gt;&lt;a href="http://youtube.com/watch?v=b-iTZJECJyE"&gt;Barcelona Competition Bouldering&lt;/a&gt;. &lt;em&gt;Just complete thuggery!&lt;/em&gt; &lt;li&gt;&lt;a href="http://youtube.com/watch?v=NVVGnYdgDbo"&gt;La Rambla&lt;/a&gt;.&amp;nbsp; &lt;em&gt;A really bad camera angle, but about halfway through just look at how crappy those holds are!&lt;/em&gt; &lt;li&gt;&lt;a href="http://youtube.com/watch?v=o4h8N3Neqgg&amp;amp;mode=related&amp;amp;search="&gt;Access Fund Boulder Project&lt;/a&gt;.&amp;nbsp; &lt;em&gt;This reminds me of how &lt;a href="http://youtube.com/watch?v=fOz5VKMp3CY"&gt;Johnny Dawes&lt;/a&gt; used to climb if anyone remembers him.&lt;/em&gt;&lt;/li&gt;&lt;/ul&gt;&lt;img src="http://lyon-smith.org/aggbug.aspx?PostID=149" width="1" height="1"&gt;</description><category domain="http://lyon-smith.org/blogs/ktthp/archive/tags/links/default.aspx">links</category><category domain="http://lyon-smith.org/blogs/ktthp/archive/tags/viral+video/default.aspx">viral video</category><category domain="http://lyon-smith.org/blogs/ktthp/archive/tags/rock+climbing/default.aspx">rock climbing</category></item><item><title>Lion vs. Alligator vs. Buffalo. Buffalo wins.</title><link>http://lyon-smith.org/blogs/ktthp/archive/2007/07/24/lion-vs-alligator-vs-buffalo-buffalo-wins.aspx</link><pubDate>Wed, 25 Jul 2007 02:55:38 GMT</pubDate><guid isPermaLink="false">21093a07-8b3d-42db-8cbf-3350fcbf5496:148</guid><dc:creator>john</dc:creator><slash:comments>0</slash:comments><description>&lt;p&gt;If you haven't already, watch this &lt;a href="http://youtube.com/watch?v=LU8DDYz68kM"&gt;amazing amateur video&lt;/a&gt; on You Tube of a baby water buffalo getting attacked by a lion.&amp;nbsp; The buffalo is then also attacked by an alligator.&amp;nbsp; Amazingly the buffalo herd arrives and fights off both attackers, and the baby buffalo walks away!&lt;/p&gt;&lt;img src="http://lyon-smith.org/aggbug.aspx?PostID=148" width="1" height="1"&gt;</description><category domain="http://lyon-smith.org/blogs/ktthp/archive/tags/links/default.aspx">links</category><category domain="http://lyon-smith.org/blogs/ktthp/archive/tags/viral+video/default.aspx">viral video</category></item></channel></rss>