<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Logaan's Site &#187; Programming</title>
	<atom:link href="http://www.logaans-site.co.uk/category/programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.logaans-site.co.uk</link>
	<description>In my own little world, world...world</description>
	<lastBuildDate>Thu, 29 Dec 2011 10:00:41 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Extract OcxState data</title>
		<link>http://www.logaans-site.co.uk/2011/08/07/extract-ocxstate-data/</link>
		<comments>http://www.logaans-site.co.uk/2011/08/07/extract-ocxstate-data/#comments</comments>
		<pubDate>Sun, 07 Aug 2011 11:45:31 +0000</pubDate>
		<dc:creator>Logaan</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.logaans-site.co.uk/?p=647</guid>
		<description><![CDATA[At work we have recently spent effort to remove our technical debt. So far we have introduced Unicode into the native code, migrated our VB6 to VB.NET, upgraded to .NET 4.0 and now we are working on 64bit support. However, we have used the Microsoft FlexGrid quite extensively in our VB6 (now VB.NET) components and [...]]]></description>
			<content:encoded><![CDATA[<p>At work we have recently spent effort to remove our technical debt. So far we have introduced Unicode into the native code, migrated our VB6 to VB.NET, upgraded to .NET 4.0 and now we are working on 64bit support.</p>
<p>However, we have used the Microsoft FlexGrid quite extensively in our VB6 (now VB.NET) components and it does not support 64bit, therefore we decided to build a compatible control which wraps the existing WinForms DataGridView control.</p>
<p>We discovered quite early on that the properties set through the designer of an ActiveX control does not generate designer code, but instead it is serialized as a resource and restored through the OcxState property.</p>
<p>Always being the one to reduce the workload I devised a way of extracting this information so that we can redo the designer set properties. I found out that I could give the control another OcxState from another ResX and I could just look at the changed properties.</p>
<p>In the project (download below) I created a form with the desired control on it, I hacked around with the designer generated code to allow me to override the OcxState.</p>
<pre class="brush: csharp; auto-links: false; title: ; notranslate">
private readonly AxHost.State state;

public DummyForm()
    : this(null)
{
}

public DummyForm(AxHost.State state)
{
    this.state = state;
    InitializeComponent();
}

//
// axMSFlexGrid1
//
this.axMSFlexGrid1.Location = new System.Drawing.Point(69, 75);
this.axMSFlexGrid1.Name = &quot;axMSFlexGrid1&quot;;
if (state == null)
    this.axMSFlexGrid1.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject(&quot;axMSFlexGrid1.OcxState&quot;)));
else
    this.axMSFlexGrid1.OcxState = state;
</pre>
<p>I used the ResXResourceReader and the ResourceSet classes to get the OcxState from my desired ResX source (the project that has the state in it I want to know). Then using reflection I compared the default state of the control (using the OcxState that the designer created) to the state I desired (with my own OcxState extracted from another ResX) and I now know what properties were changed on the designer.</p>
<p>In this project I have referenced the Microsoft FlexGrid but in theory it could be any ActiveX control.</p>
<p><a href="http://www.logaans-site.co.uk/wp-content/uploads/2011/08/GetOcxState.zip">Download Project</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.logaans-site.co.uk/2011/08/07/extract-ocxstate-data/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>AssocQueryString (ANSI version) does not work in XP or Vista</title>
		<link>http://www.logaans-site.co.uk/2011/03/26/assocquerystring-ansi-version-does-not-work-in-xp-or-vista/</link>
		<comments>http://www.logaans-site.co.uk/2011/03/26/assocquerystring-ansi-version-does-not-work-in-xp-or-vista/#comments</comments>
		<pubDate>Sat, 26 Mar 2011 19:04:30 +0000</pubDate>
		<dc:creator>Logaan</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.logaans-site.co.uk/?p=597</guid>
		<description><![CDATA[This is going back awhile but colleague and I had a hell of a time recently trying to solve a problem where the Windows API method &#8220;AssocQueryString&#8221; did not seem to work in XP. After creating a test application in various different configurations and testing it on several platforms we found that the ANSI version [...]]]></description>
			<content:encoded><![CDATA[<p>This is going back awhile but colleague and I had a hell of a time recently trying to solve a problem where the Windows API method &#8220;AssocQueryString&#8221; did not seem to work in XP.</p>
<p>After creating a test application in various different configurations and testing it on several platforms we found that the ANSI version of AssocQueryString just did not work.</p>
<p>It was not until this evidence came to light that we finally found a connect article (in the depths of my browser history) describing this issue.</p>
<p>Our codebase might be quite rare (it is still currently 100% ANSI) and I would expect many to already be using Unicode&#8230; the workaround was to use it in Unicode and use conversions to interact with the rest of the codebase.</p>
<p>So yeah&#8230; hopefully others might find this elightening and save hours of hair pulling.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.logaans-site.co.uk/2011/03/26/assocquerystring-ansi-version-does-not-work-in-xp-or-vista/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to invoke a method on a COM object in C#</title>
		<link>http://www.logaans-site.co.uk/2011/02/14/how-to-invoke-a-method-on-a-com-object-in-c/</link>
		<comments>http://www.logaans-site.co.uk/2011/02/14/how-to-invoke-a-method-on-a-com-object-in-c/#comments</comments>
		<pubDate>Mon, 14 Feb 2011 15:05:40 +0000</pubDate>
		<dc:creator>Logaan</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Code Snippet]]></category>

		<guid isPermaLink="false">http://www.logaans-site.co.uk/?p=609</guid>
		<description><![CDATA[Where I work we often need to invoke methods on a COM object that has been developed in VB6 or in .NET. I wrote this helper class for speed it along.]]></description>
			<content:encoded><![CDATA[<p>Where I work we often need to invoke methods on a COM object that has been developed in VB6 or in .NET. I wrote this helper class for speed it along.</p>
<pre class="brush: csharp; auto-links: false; title: ; notranslate">
public static class ActiveX
{
    public static object Invoke(string @namespace, string @class, string method, params object[] parameters)
    {
        var progId = string.Format(&quot;{0}.{1}&quot;, @namespace, @class);
        return Invoke(progId, method, parameters);
    }

    public static object Invoke(string progId, string method, params object[] parameters)
    {
        var type = Type.GetTypeFromProgID(progId);
        var comObject = Activator.CreateInstance(type);

        return type.InvokeMember(method, BindingFlags.InvokeMethod, null, comObject, parameters);
    }
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.logaans-site.co.uk/2011/02/14/how-to-invoke-a-method-on-a-com-object-in-c/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Generic attributes would be awesome</title>
		<link>http://www.logaans-site.co.uk/2010/08/14/generic-attributes-would-be-awesome/</link>
		<comments>http://www.logaans-site.co.uk/2010/08/14/generic-attributes-would-be-awesome/#comments</comments>
		<pubDate>Sat, 14 Aug 2010 17:16:58 +0000</pubDate>
		<dc:creator>Logaan</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[.NET]]></category>
		<category><![CDATA[C#]]></category>

		<guid isPermaLink="false">http://www.logaans-site.co.uk/?p=589</guid>
		<description><![CDATA[Generic attributes would be awesome]]></description>
			<content:encoded><![CDATA[<p>Generic attributes would be awesome</p>
]]></content:encoded>
			<wfw:commentRss>http://www.logaans-site.co.uk/2010/08/14/generic-attributes-would-be-awesome/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Composite WPF Presentation Model item template</title>
		<link>http://www.logaans-site.co.uk/2010/01/06/composite-wpf-presentation-model-item-template/</link>
		<comments>http://www.logaans-site.co.uk/2010/01/06/composite-wpf-presentation-model-item-template/#comments</comments>
		<pubDate>Wed, 06 Jan 2010 18:16:33 +0000</pubDate>
		<dc:creator>Logaan</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Item Template]]></category>
		<category><![CDATA[VS2008]]></category>

		<guid isPermaLink="false">http://www.logaans-site.co.uk/?p=555</guid>
		<description><![CDATA[Neat little template I designed for use at work which is an improvement over the ViewModel code snippet. Download PresentationModel item template How to use It is a bit unusual the way I have written this. Instead of specifying the file name for the item, it is the view name that is to be used. [...]]]></description>
			<content:encoded><![CDATA[<p>Neat little template I designed for use at work which is an improvement over the ViewModel code snippet.</p>
<p><a href="http://www.logaans-site.co.uk/wp-content/uploads/2010/01/PresentationModel.zip">Download PresentationModel item template</a></p>
<p><strong>How to use</strong></p>
<p>It is a bit unusual the way I have written this. Instead of specifying the file name for the item, it is the view <em>name </em>that is to be used.</p>
<p>When prompted for the ViewName, specifying &#8220;MainWindow&#8221; will create:</p>
<p>A xaml user control called MainWindowView.xaml.</p>
<p>An interface called IMainWindowView.</p>
<p>An interface called IMainWindowViewModel.</p>
<p>A class called MainWindowViewModel.</p>
<p>(Some of this is very similar to the ViewModel code snippet)</p>
]]></content:encoded>
			<wfw:commentRss>http://www.logaans-site.co.uk/2010/01/06/composite-wpf-presentation-model-item-template/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Interface Properties</title>
		<link>http://www.logaans-site.co.uk/2009/11/25/interface-properties/</link>
		<comments>http://www.logaans-site.co.uk/2009/11/25/interface-properties/#comments</comments>
		<pubDate>Wed, 25 Nov 2009 17:09:27 +0000</pubDate>
		<dc:creator>Logaan</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Code Snippet]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.logaans-site.co.uk/?p=540</guid>
		<description><![CDATA[Basically rip-offs of the prop and propg code snippets you get with Visual Studio but without the scope or accessor keywords. iprop ipropg]]></description>
			<content:encoded><![CDATA[<p>Basically rip-offs of the <em>prop </em>and <em>propg </em>code snippets you get with Visual Studio but without the scope or accessor keywords.</p>
<p><strong>iprop</strong></p>
<pre class="brush: xml; auto-links: false; title: ; notranslate">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot; ?&gt;
&lt;CodeSnippets  xmlns=&quot;http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet&quot;&gt;
	&lt;CodeSnippet Format=&quot;1.0.0&quot;&gt;
		&lt;Header&gt;
			&lt;Title&gt;iprop&lt;/Title&gt;
			&lt;Shortcut&gt;iprop&lt;/Shortcut&gt;
			&lt;Description&gt;Code snippet for an automatically implemented property on an interface&lt;/Description&gt;
			&lt;Author&gt;Alex Boyne-Aitken&lt;/Author&gt;
			&lt;SnippetTypes&gt;
				&lt;SnippetType&gt;Expansion&lt;/SnippetType&gt;
			&lt;/SnippetTypes&gt;
		&lt;/Header&gt;
		&lt;Snippet&gt;
			&lt;Declarations&gt;
				&lt;Literal&gt;
					&lt;ID&gt;type&lt;/ID&gt;
					&lt;ToolTip&gt;Property type&lt;/ToolTip&gt;
					&lt;Default&gt;int&lt;/Default&gt;
				&lt;/Literal&gt;
				&lt;Literal&gt;
					&lt;ID&gt;property&lt;/ID&gt;
					&lt;ToolTip&gt;Property name&lt;/ToolTip&gt;
					&lt;Default&gt;MyProperty&lt;/Default&gt;
				&lt;/Literal&gt;
			&lt;/Declarations&gt;
			&lt;Code Language=&quot;csharp&quot;&gt;&lt;![CDATA[$type$ $property$ { get; set; }$end$]]&gt;
			&lt;/Code&gt;
		&lt;/Snippet&gt;
	&lt;/CodeSnippet&gt;
&lt;/CodeSnippets&gt;
</pre>
<p><strong>ipropg</strong></p>
<pre class="brush: xml; auto-links: false; title: ; notranslate">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot; ?&gt;
&lt;CodeSnippets  xmlns=&quot;http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet&quot;&gt;
	&lt;CodeSnippet Format=&quot;1.0.0&quot;&gt;
		&lt;Header&gt;
			&lt;Title&gt;ipropg&lt;/Title&gt;
			&lt;Shortcut&gt;ipropg&lt;/Shortcut&gt;
			&lt;Description&gt;Code snippet for an automatically implemented property with a 'get' accessor for interfaces&lt;/Description&gt;
			&lt;Author&gt;Alex Boyne-Aitken&lt;/Author&gt;
			&lt;SnippetTypes&gt;
				&lt;SnippetType&gt;Expansion&lt;/SnippetType&gt;
			&lt;/SnippetTypes&gt;
		&lt;/Header&gt;
		&lt;Snippet&gt;
			&lt;Declarations&gt;
				&lt;Literal&gt;
					&lt;ID&gt;type&lt;/ID&gt;
					&lt;ToolTip&gt;Property type&lt;/ToolTip&gt;
					&lt;Default&gt;int&lt;/Default&gt;
				&lt;/Literal&gt;
				&lt;Literal&gt;
					&lt;ID&gt;property&lt;/ID&gt;
					&lt;ToolTip&gt;Property name&lt;/ToolTip&gt;
					&lt;Default&gt;MyProperty&lt;/Default&gt;
				&lt;/Literal&gt;
			&lt;/Declarations&gt;
			&lt;Code Language=&quot;csharp&quot;&gt;&lt;![CDATA[$type$ $property$ { get; }$end$]]&gt;
			&lt;/Code&gt;
		&lt;/Snippet&gt;
	&lt;/CodeSnippet&gt;
&lt;/CodeSnippets&gt;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.logaans-site.co.uk/2009/11/25/interface-properties/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to learn Programming</title>
		<link>http://www.logaans-site.co.uk/2009/11/12/how-to-learn-programming/</link>
		<comments>http://www.logaans-site.co.uk/2009/11/12/how-to-learn-programming/#comments</comments>
		<pubDate>Thu, 12 Nov 2009 17:45:22 +0000</pubDate>
		<dc:creator>Logaan</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Tips and Tricks]]></category>

		<guid isPermaLink="false">http://www.logaans-site.co.uk/?p=532</guid>
		<description><![CDATA[Read a fantastic article on Life Hacker on how to teach yourself computer programming: http://lifehacker.com/5401954/programmer-101-teach-yourself-how-to-code My only comment would be pick a language that is based on C-like syntax (rather than use Python or VB) because although the syntax may seem harder, the syntax is more transferrable to other languages and it would give you [...]]]></description>
			<content:encoded><![CDATA[<p>Read a fantastic article on Life Hacker on how to teach yourself computer programming: <a href="http://lifehacker.com/5401954/programmer-101-teach-yourself-how-to-code">http://lifehacker.com/5401954/programmer-101-teach-yourself-how-to-code</a></p>
<p>My only comment would be pick a language that is based on C-like syntax (rather than use Python or VB) because although the syntax may seem harder, the syntax is more transferrable to other languages and it would give you a head start.</p>
<p>In my personal experience, a book only served as a reference. I found books that taught me how to do something soon became too basic for my needs and often there are plenty of guides on the internet that is a good replacement. Instead you will find much of my library consists of reference books, hint, tips and advanced topics.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.logaans-site.co.uk/2009/11/12/how-to-learn-programming/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CyTS library stalling</title>
		<link>http://www.logaans-site.co.uk/2009/11/07/cyts-library-stalling/</link>
		<comments>http://www.logaans-site.co.uk/2009/11/07/cyts-library-stalling/#comments</comments>
		<pubDate>Sat, 07 Nov 2009 17:48:19 +0000</pubDate>
		<dc:creator>Logaan</dc:creator>
				<category><![CDATA[PHP]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Teamspeak]]></category>

		<guid isPermaLink="false">http://www.logaans-site.co.uk/?p=513</guid>
		<description><![CDATA[On our guild website, we have a block in the portal that shows who is currently on teamspeak. This uses the CyTS library to connect and get such information and occasionally it would cause the portal to stop loading. In each case I would get home, load it up and not find any problems at [...]]]></description>
			<content:encoded><![CDATA[<p>On our guild website, we have a block in the portal that shows who is currently on teamspeak. This uses the CyTS library to connect and get such information and occasionally it would cause the portal to stop loading.</p>
<p>In each case I would get home, load it up and not find any problems at all. Well today was a different matter, I was able to pin point the exact issue. For some reason the library connects to the server but then stalls when receiving information from the server.</p>
<p>I should tell you know, this is not a perfect fix but it does the job. I did look into other options like switch socket blocking on and off and such other approaches, but it seems that if <em>fgets</em> reads more than 1 byte, it stalls. This is a bug in PHP that has hung around for a while.</p>
<p>I have changed the <em>_readcall</em> function to read the first byte, check it for failure then continue with the rest.</p>
<pre class="brush: php; title: ; notranslate">
function _readcall()
{
	if (!is_resource($this-&gt;sCon))
		return false;

	// HACK : Workaround to fail fast
	$first = fgets($this-&gt;sCon, 1);

	if($first === false)
		return false;

	$sRead = '';
	do
	{
		$cRead = $first.fgets($this-&gt;sCon);
		$first = '';

		$sRead .= $cRead;
	} while ($cRead != CYTS_SYN &amp;&amp; $cRead != CYTS_OK &amp;&amp; strtoupper(substr($cRead, 0, 5)) != &quot;ERROR&quot;);
	return $sRead;
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.logaans-site.co.uk/2009/11/07/cyts-library-stalling/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>View model property</title>
		<link>http://www.logaans-site.co.uk/2009/11/02/view-model-property/</link>
		<comments>http://www.logaans-site.co.uk/2009/11/02/view-model-property/#comments</comments>
		<pubDate>Mon, 02 Nov 2009 20:07:04 +0000</pubDate>
		<dc:creator>Logaan</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Code Snippet]]></category>

		<guid isPermaLink="false">http://www.logaans-site.co.uk/?p=508</guid>
		<description><![CDATA[Because I am so lazy :P]]></description>
			<content:encoded><![CDATA[<p>Because I am so lazy :P</p>
<pre class="brush: xml; auto-links: false; title: ; notranslate">
&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot; ?&gt;
&lt;CodeSnippets  xmlns=&quot;http://schemas.microsoft.com/VisualStudio/2005/CodeSnippet&quot;&gt;
	&lt;CodeSnippet Format=&quot;1.0.0&quot;&gt;
		&lt;Header&gt;
			&lt;Title&gt;View model property snippet&lt;/Title&gt;
			&lt;Shortcut&gt;vmprop&lt;/Shortcut&gt;
			&lt;Description&gt;&lt;/Description&gt;
			&lt;Author&gt;Alex Boyne-Aitken&lt;/Author&gt;
			&lt;SnippetTypes&gt;
				&lt;SnippetType&gt;Expansion&lt;/SnippetType&gt;
			&lt;/SnippetTypes&gt;
		&lt;/Header&gt;
		&lt;Snippet&gt;
			&lt;Declarations&gt;
        &lt;Literal&gt;
          &lt;ID&gt;name&lt;/ID&gt;
          &lt;ToolTip&gt;Property name&lt;/ToolTip&gt;
          &lt;Default&gt;Field&lt;/Default&gt;
        &lt;/Literal&gt;
        &lt;Literal&gt;
          &lt;ID&gt;field&lt;/ID&gt;
          &lt;ToolTip&gt;Field name&lt;/ToolTip&gt;
          &lt;Default&gt;field&lt;/Default&gt;
        &lt;/Literal&gt;
        &lt;Literal&gt;
          &lt;ID&gt;type&lt;/ID&gt;
          &lt;ToolTip&gt;Type&lt;/ToolTip&gt;
          &lt;Default&gt;object&lt;/Default&gt;
        &lt;/Literal&gt;
			&lt;/Declarations&gt;
			&lt;Code Language=&quot;csharp&quot;&gt;
        &lt;![CDATA[
    $type$ $field$;
    public $type$ $name$
    {
        get { return $field$; }
        set
        {
            if ($field$ == value)
                return;

            $field$ = value;
            SendPropertyChanged(&quot;$name$&quot;);
        }
    }
			$end$]]&gt;
			&lt;/Code&gt;
		&lt;/Snippet&gt;
	&lt;/CodeSnippet&gt;
&lt;/CodeSnippets&gt;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.logaans-site.co.uk/2009/11/02/view-model-property/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MSBuild creating lots of temp files</title>
		<link>http://www.logaans-site.co.uk/2009/10/23/msbuild-creating-lots-of-temp-files/</link>
		<comments>http://www.logaans-site.co.uk/2009/10/23/msbuild-creating-lots-of-temp-files/#comments</comments>
		<pubDate>Fri, 23 Oct 2009 09:19:49 +0000</pubDate>
		<dc:creator>Logaan</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[MSBuild]]></category>

		<guid isPermaLink="false">http://www.logaans-site.co.uk/?p=497</guid>
		<description><![CDATA[UPDATE: I found a msdn forum post with exactly the same issue: http://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/42647eff-ecb8-412c-a884-a152b6fdd40d It turns out that it is NOT msbuild but it is SN.exe leaving the temp files behind when resigning assemblies. I suppose you could easily come to this conclusion when watching the build and those files are flashing by so quickly. On [...]]]></description>
			<content:encoded><![CDATA[<p><strong>UPDATE: </strong></p>
<p>I found a msdn forum post with exactly the same issue: <a href="http://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/42647eff-ecb8-412c-a884-a152b6fdd40d" target="_blank">http://social.msdn.microsoft.com/Forums/en-US/netfxbcl/thread/42647eff-ecb8-412c-a884-a152b6fdd40d</a></p>
<p>It turns out that it is <strong>NOT</strong> msbuild but it is SN.exe leaving the temp files behind when resigning assemblies. I suppose you could easily come to this conclusion when watching the build and those files are flashing by so quickly.</p>
<p>On reflection a custom task will not help either&#8230;</p>
<p>This post has more details on the issue with a link to a hot fix for Server 2003: <a href="http://blogs.msdn.com/pfedev/archive/2008/10/24/sn-exe-and-empty-temp-files-in-temp.aspx" target="_blank">http://blogs.msdn.com/pfedev/archive/2008/10/24/sn-exe-and-empty-temp-files-in-temp.aspx</a></p>
<p>If you are using Server 2008 I would not recommend installing it.</p>
<p><span id="more-497"></span><br />
<strong>Original:</strong></p>
<p>Recently at work we have be observing a very odd behaviour, a particular set of builds has been slowing by about 30 minutes every night.</p>
<p>We discovered that hundreds of temporary files were being created by the msbuild exec task. What happens is that the exec task will created a temp file, then use the temp file name to create a batch file with the command in it. In most cases it will delete the temp file and the batch file. If you are quick enough you can pause the build and look in the temp folder and observe these files.</p>
<p>Now the strange thing is we have observed a specific case of when msbuild will not delete that temporary file, thus adding a cumalative amount of time every night when it is trying to find a new temp file name. This occurs when we resign our assemblies using SN. If you use SN to verify the assemblies the temp file is cleaned up afterwards.</p>
<p>This is quite a baffling problem, when calling the same executable with a different command it just works, seems odd to me that it would cause such an issue. There is also little on the internet that hints at this issue, I suppose if people are careul and look after the servers with regular cleanup tasks this issue might never arise.</p>
<p>So at the moment to work around the issue we have written temp folder clean up tasks and a sceduled disk clean up task on the server. I might write a set of specific tasks wrapping the SN executable and its command line arguments to reduce the need for such measures.</p>
<p>If I can get any sort of grasp on the actual issue then I will create and link to an MSConnect issue.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.logaans-site.co.uk/2009/10/23/msbuild-creating-lots-of-temp-files/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

