<?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>richard-slater.co.uk</title>
	<atom:link href="http://www.richard-slater.co.uk/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.richard-slater.co.uk</link>
	<description>Jesus, Life, Programming and Systems Administration</description>
	<lastBuildDate>Sun, 07 Mar 2010 21:53:34 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Lack of AutoEllipsis support in ToolStripSystemRenderer</title>
		<link>http://www.richard-slater.co.uk/archives/2010/03/07/lack-of-autoellipsis-support-in-toolstripsystemrenderer/</link>
		<comments>http://www.richard-slater.co.uk/archives/2010/03/07/lack-of-autoellipsis-support-in-toolstripsystemrenderer/#comments</comments>
		<pubDate>Sun, 07 Mar 2010 21:03:04 +0000</pubDate>
		<dc:creator>Richard Slater</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[EVEMon]]></category>
		<category><![CDATA[WinForms]]></category>

		<guid isPermaLink="false">http://www.richard-slater.co.uk/?p=753</guid>
		<description><![CDATA[AutoEllipsis is a property introduced to System.Windows.Forms.Label with .NET 3.0, which in the event of the text overflowing the rendering rectangle of the Label will trim the end and add a Ellipsis (&#8220;…&#8221;), if this does occur the ToolTip for the label will also be set to the full (untrimmed text).
Unfortunately this functionality is not [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.label.autoellipsis%28VS.85%29.aspx">AutoEllipsis</a> is a property introduced to System.Windows.Forms.Label with .NET 3.0, which in the event of the text overflowing the rendering rectangle of the Label will trim the end and add a Ellipsis (&#8220;…&#8221;), if this does occur the <a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.tooltip.aspx">ToolTip</a> for the label will also be set to the full (untrimmed text).</p>
<p>Unfortunately this functionality is not available for <a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.toolstripstatuslabel.aspx">ToolStripStatusLabel</a>. To make things worse in the event the text overflows it disappears completely. This bug, oversight, feature or whatever you want to call it cause some confusion after the release of EVEMon 1.3.0.1912. Several people assumed the new more verbose status bar was broken, being empty and all.</p>
<p>We put together a kludge fix, which would set the text and if it overflowed try to guess the length with <a href="http://msdn.microsoft.com/en-us/library/6xe5hazb.aspx">Graphics.MeasureString</a>. This worked fairly well, it cause some flickering when resizing the window and would leave a small gap on the right hand side of the <a href="http://msdn.microsoft.com/en-us/library/system.windows.forms.statusstrip.aspx">StatusStrip</a>.</p>
<p>I knew there must be a better way, and seeing an article about the <a href="http://msdn.microsoft.com/en-us/library/system.drawing.stringformat.aspx">StringFormat</a> class reminded me of the need to find it. Searching about a bit found me a post on <a href="http://discuss.joelonsoftware.com/default.asp?dotnet.12.597246.5">Joel on Software</a>, I refined the code a little and came up with this (which is basically identical to Tom&#8217;s solution):</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF;">public</span> <span style="color: #FF0000;">class</span> AutoEllipsisToolStripRenderer <span style="color: #008000;">:</span> ToolStripSystemRenderer
<span style="color: #000000;">&#123;</span>
  <span style="color: #0600FF;">protected</span> <span style="color: #0600FF;">override</span> <span style="color: #0600FF;">void</span> OnRenderItemText<span style="color: #000000;">&#40;</span>ToolStripItemTextRenderEventArgs e<span style="color: #000000;">&#41;</span>
  <span style="color: #000000;">&#123;</span>
    ToolStripStatusLabel label <span style="color: #008000;">=</span> e.<span style="color: #0000FF;">Item</span> <span style="color: #0600FF;">as</span> ToolStripStatusLabel<span style="color: #008000;">;</span>
&nbsp;
    <span style="color: #0600FF;">if</span> <span style="color: #000000;">&#40;</span>label <span style="color: #008000;">==</span> <span style="color: #0600FF;">null</span><span style="color: #000000;">&#41;</span>
    <span style="color: #000000;">&#123;</span>
      <span style="color: #0600FF;">base</span>.<span style="color: #0000FF;">OnRenderItemText</span><span style="color: #000000;">&#40;</span>e<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
      return<span style="color: #008000;">;</span>
    <span style="color: #000000;">&#125;</span>
&nbsp;
    TextRenderer.<span style="color: #0000FF;">DrawText</span><span style="color: #000000;">&#40;</span>e.<span style="color: #0000FF;">Graphics</span>,
      label.<span style="color: #0000FF;">Text</span>,
      label.<span style="color: #0000FF;">Font</span>,
      e.<span style="color: #0000FF;">TextRectangle</span>,
      label.<span style="color: #0000FF;">ForeColor</span>,
      TextFormatFlags.<span style="color: #0000FF;">EndEllipsis</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
  <span style="color: #000000;">&#125;</span>
<span style="color: #000000;">&#125;</span></pre></div></div>

<p>You need to wire this code into your StatusStrip:</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #0600FF;">this</span>.<span style="color: #0000FF;">MainStatusStrip</span>.<span style="color: #0000FF;">Renderer</span> <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> AutoEllipsisToolStripRenderer<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span></pre></div></div>

<p>To the ToolStripStatusLabel will also need it&#8217;s Spring property set to true, and if you want the text left aligned the TextAlign Property will need to be set to MiddleLeft.</p>
<p>If you want the ToolTip to work correctly the StatusStrip will need to have ShowItemToolTips set to work, and the ToolStripStatusLabel AutoToolTip set to true. It isn&#8217;t perfect as the ToolTip is displayed when the text is not truncated, but it is close enough for my purposes.</p>
<p>I am exploring WPF at the moment, I was glad to see the default behaviour of a <a href="http://msdn.microsoft.com/en-us/library/system.windows.controls.primitives.statusbar.aspx">StatusBar</a> was to just stop rendering the text at the bounds of control, an ellipsis could be added with the <a href="http://msdn.microsoft.com/en-us/library/system.windows.controls.textblock.texttrimming.aspx">TextTrimming</a> and <a href="http://msdn.microsoft.com/en-us/library/system.windows.controls.textblock.textwrapping.aspx">TextWraping</a> properties:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;"><span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;statusbar</span> <span style="color: #000066;">HorizontalAlignment</span>=<span style="color: #ff0000;">&quot;Left&quot;</span> <span style="color: #000066;">Margin</span>=<span style="color: #ff0000;">&quot;0,102,0,0&quot;</span> <span style="color: #000066;">Name</span>=<span style="color: #ff0000;">&quot;MainStatusBar&quot;</span> <span style="color: #000066;">VerticalAlignment</span>=<span style="color: #ff0000;">&quot;Top&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;statusbaritem<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;textblock</span> <span style="color: #000066;">TextWrapping</span>=<span style="color: #ff0000;">&quot;NoWrap&quot;</span> <span style="color: #000066;">TextTrimming</span>=<span style="color: #ff0000;">&quot;CharacterEllipsis&quot;</span><span style="color: #000000; font-weight: bold;">&gt;</span></span>
            Some Text Goes Here, this text may be very long as demonstrated here. In the event we run out of space an ellipsis is used.
        <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/textblock<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
    <span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/statusbaritem<span style="color: #000000; font-weight: bold;">&gt;</span></span></span>
<span style="color: #009900;"><span style="color: #000000; font-weight: bold;">&lt;/statusbar<span style="color: #000000; font-weight: bold;">&gt;</span></span></span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://www.richard-slater.co.uk/archives/2010/03/07/lack-of-autoellipsis-support-in-toolstripsystemrenderer/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>LINQPad Crash</title>
		<link>http://www.richard-slater.co.uk/archives/2010/03/02/linqpad-crash/</link>
		<comments>http://www.richard-slater.co.uk/archives/2010/03/02/linqpad-crash/#comments</comments>
		<pubDate>Tue, 02 Mar 2010 21:48:18 +0000</pubDate>
		<dc:creator>Richard Slater</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Crash]]></category>
		<category><![CDATA[Exception]]></category>
		<category><![CDATA[LINQ]]></category>
		<category><![CDATA[LINQPad]]></category>

		<guid isPermaLink="false">http://www.richard-slater.co.uk/?p=746</guid>
		<description><![CDATA[I found myself using LINQPad more often than creating console applications, so much so I dicided to make the small but worth while investment in the optional &#8220;Autocompletion&#8221; (Intelisense-like) component. The licence is great because I can have it installed on all three of my PCs without having to buy extra licences.
I was figuring out the [...]]]></description>
			<content:encoded><![CDATA[<p>I found myself using <a href="http://www.linqpad.net/">LINQPad</a> more often than creating console applications, so much so I dicided to make the small but worth while investment in the optional &#8220;Autocompletion&#8221; (Intelisense-like) component. The licence is great because I can have it installed on all three of my PCs without having to buy extra licences.</p>
<p>I was figuring out the limits of the Math.Pow function a few days ago on the laptop when the LINQPad upgrade message appeared, not sure what happened next because LINQPad crashed with the following exception.</p>
<p><strong>System Specification:</strong></p>
<ul>
<li>Windows 7 Home Premium x64</li>
<li>.NET v2.0.50727 (+3.0 &amp; 3.5)</li>
<li>.NET v4.0.20506</li>
<li>VisualStudio 2010 Beta1</li>
</ul>
<pre>System.AccessViolationException: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.

   at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG&amp; msg)
   at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
   at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
   at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
   at System.Windows.Forms.Form.ShowDialog(IWin32Window owner)
   at LINQPad.Program.ProcessException(Exception ex)
   at LINQPad.Program.Start(String[] args)
   at LINQPad.ProgramStarter.Run(String[] args)
   at LINQPad.Loader.Main(String[] args)</pre>
<p>If anyone has any theories as to how this can be fixed I would be very apprecitive if you could post in the comments.</p>
<p>So far I have tried:</p>
<ul>
<li>Reinstalling from the latest (2.10.1)<strong> </strong>from the LINQPad website.</li>
<li>Restarted the computer.</li>
<li>Removing LINQPad through Add/Remove Programs.</li>
<li>Remove LINQPAD manually.</li>
<li>Rename %APPDATA%\LINQPad.</li>
<li>Looked for Native Images in C:\Windows\assembly &#8211; None there</li>
</ul>
<p>It seems to me that LINQPad throws some exception, which it&#8217;s built in exception handler tries to handle then fails, this probably means that the above stack trace is probably not indicative of what is causing the problem. Not that I think it will make a difference but I am going to try upgrading to Visual Studio 2010 RC tomorrow then at least I wll be able to use LINQPad for .NET 4.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.richard-slater.co.uk/archives/2010/03/02/linqpad-crash/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Preventing the PictureBox control from locking files</title>
		<link>http://www.richard-slater.co.uk/archives/2010/02/28/preventing-the-picturebox-control-from-locking-files/</link>
		<comments>http://www.richard-slater.co.uk/archives/2010/02/28/preventing-the-picturebox-control-from-locking-files/#comments</comments>
		<pubDate>Sun, 28 Feb 2010 20:18:58 +0000</pubDate>
		<dc:creator>Richard Slater</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[EVEMon]]></category>

		<guid isPermaLink="false">http://www.richard-slater.co.uk/?p=739</guid>
		<description><![CDATA[One of our more regular contributors to EVEMon posted on our forums showing that the application was incapable of updating cached files (specifically images), after a bit testing I discovered the following Exception was being thrown when trying to overwrite the file in question:
System.IO.IOException: The process cannot access the file 'path\filename' because it is being [...]]]></description>
			<content:encoded><![CDATA[<p>One of our more regular contributors to <a href="http://evemon.battleclinic.com/">EVEMon</a> posted on our forums showing that the application was incapable of updating cached files (specifically images), after a bit testing I discovered the following Exception was being thrown when trying to overwrite the file in question:</p>
<pre>System.IO.IOException: The process cannot access the file 'path\filename' because it is being used by another process.
   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.IO.File.InternalCopy(String sourceFileName, String destFileName, Boolean overwrite)
   at System.IO.File.Copy(String sourceFileName, String destFileName, Boolean overwrite)
   at EVEMon.Common.FileHelper.OverwriteOrWarnTheUser(String srcFileName, String destFileName) in EVEMon.Common\FileHelper.cs:line 108
   at EVEMon.Common.FileHelper.OverwriteOrWarnTheUser(String destFileName, Func`2 writeContentFunc) in EVEMon.Common\FileHelper.cs:line 82
   at EVEMon.Common.Controls.CharacterPortrait.SavePortraitToCache(Image newImage) in EVEMon.Common\Controls\CharacterPortrait.cs:line 248
</pre>
<p>After a bit of searching around I discovered a <a href="http://stackoverflow.com/questions/2188464/net-app-locks-file">post on StackOverflow</a> identifying that System.Drawing.Bitmap(string filename) would lock the filename until the Bitmap was disposed of. The post presented a solution but no code, A bit of further searching confirmed my expectation that <a href="http://msdn.microsoft.com/en-us/library/4sahykhd.aspx">Image.FromFile(string filename)</a> was subject to the same locking behaviour:</p>
<blockquote><p>The file remains locked until the <a id="ctl00_MTCS_main_ctl51_ctl00_ctl00" onclick="javascript:Track('ctl00_MTCS_main_ctl51_ctl00_contenthere|ctl00_MTCS_main_ctl51_ctl00_ctl00',this);" href="http://msdn.microsoft.com/en-us/library/system.drawing.image.aspx">Image</a> is disposed.</p></blockquote>
<p>A bit more searching identified another <a href="http://stackoverflow.com/questions/542217/load-a-bitmapsource-and-save-using-the-same-name-in-wpf-ioexception">post on StackOverflow</a> which gave me the basic syntax and structure for the code I was going to need to implement this in EVEMon. The final code looks like this:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>189
190
191
192
193
194
195
196
</pre></td><td class="code"><pre class="csharp" style="font-family:monospace;">MemoryStream stream <span style="color: #008000;">=</span> <span style="color: #008000;">new</span> MemoryStream<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
&nbsp;
<span style="color: #FF0000;">byte</span><span style="color: #000000;">&#91;</span><span style="color: #000000;">&#93;</span> imageBytes <span style="color: #008000;">=</span> File.<span style="color: #0000FF;">ReadAllBytes</span><span style="color: #000000;">&#40;</span>cacheFileName<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
stream.<span style="color: #0000FF;">Write</span><span style="color: #000000;">&#40;</span>imageBytes, <span style="color: #FF0000;">0</span>, imageBytes.<span style="color: #0000FF;">Length</span><span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
stream.<span style="color: #0000FF;">Position</span> <span style="color: #008000;">=</span> <span style="color: #FF0000;">0</span><span style="color: #008000;">;</span>
&nbsp;
var image <span style="color: #008000;">=</span> Image.<span style="color: #0000FF;">FromStream</span><span style="color: #000000;">&#40;</span>stream<span style="color: #000000;">&#41;</span><span style="color: #008000;">;</span>
<span style="color: #0600FF;">return</span> image<span style="color: #008000;">;</span></pre></td></tr></table></div>

<p>It appears that GDI+ will lock any image that is loaded into a control in WinForms and WPF, several comments on StackOverflow and byte.com suggested that even disposing of the control and the FileStream was not a reliable way of being able to write to the file so the above method is seems to be be the best solution all round.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.richard-slater.co.uk/archives/2010/02/28/preventing-the-picturebox-control-from-locking-files/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>OneNote vs Evernote</title>
		<link>http://www.richard-slater.co.uk/archives/2010/02/27/onenote-vs-evernote/</link>
		<comments>http://www.richard-slater.co.uk/archives/2010/02/27/onenote-vs-evernote/#comments</comments>
		<pubDate>Sat, 27 Feb 2010 20:11:33 +0000</pubDate>
		<dc:creator>Richard Slater</dc:creator>
				<category><![CDATA[Diary]]></category>
		<category><![CDATA[Misc.]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Sys. Admin.]]></category>

		<guid isPermaLink="false">http://www.richard-slater.co.uk/?p=734</guid>
		<description><![CDATA[Somewhere in the middle of 2007 I was encouraged to use OneNote to clear my desk and move to a &#8220;paperless&#8221; system, initially this was a little painful as it seemed a gargantuan task to scan in all of the bits of paper on and around my desk that appeared to contain useful information.
As it [...]]]></description>
			<content:encoded><![CDATA[<p>Somewhere in the middle of 2007 I was encouraged to use <a class='wikipedia' href='http://en.wikipedia.org/wiki/OneNote' title='Wikipedia article on OneNote'>OneNote</a> to clear my desk and move to a &#8220;paperless&#8221; system, initially this was a little painful as it seemed a gargantuan task to scan in all of the bits of paper on and around my desk that appeared to contain useful information.</p>
<p>As it turned out I realised that if a bit of paper was covered by another (or in fact covered by anything) it wasn&#8217;t that important to the execution of my role and could probably be thrown in the bin.</p>
<p>At the time I was not using Microsoft Office at home, opting to use <a class='wikipedia' href='http://en.wikipedia.org/wiki/OpenOffice' title='Wikipedia article on OpenOffice'>OpenOffice</a> for the limited needs I had for productivity software. I did however want a better way of organising my paperwork at home, OneNote 2007 came in at about £70 which isn&#8217;t unreasonable for what you got. Then I discovered <a class='wikipedia' href='http://en.wikipedia.org/wiki/Evernote' title='Wikipedia article on Evernote'>Evernote</a>.</p>
<p>Seemed perfect, I don&#8217;t generate so much paperwork that I would bust the 40mb/month limit on the free account. In the end I decided to adopt Evernote at home and continue to use OneNote at work, it proved quite a handy separation of work and life.</p>
<p>Recently I have run into two problems that are pushing me towards using Evernote for everything, and ditching OneNote entirely:</p>
<ol>
<li>Evernote handles PDFs really well, you drag them in and they are displayed using the Foxit rendering engine. It just works. OneNote on the other hand plain old embeds them into the note, great now how is that different from having them in a folder in My Documents.</li>
<li>Evernote 3.5 has vastly improved the synchronization mechanism meaning that I can safely put something on Evernote on my PC and it will be on my laptop shortly after it is turned on next. Microsoft has tried to get this kind of functionality into OneNote and <a class='wikipedia' href='http://en.wikipedia.org/wiki/SharePoint' title='Wikipedia article on SharePoint'>SharePoint</a> however it just doesn&#8217;t work that well, it is too slow and there seems to be a 10 minute refresh cycle hard coded into the product.</li>
</ol>
<p>I am still not sure that I want to ditch OneNote entirely, the 2010 version has some nice labour saving devices built in such as quick screen clippings and image formatting with the fluid user interface. Nothing in OneNote 2010 screams &#8220;don&#8217;t leave me&#8221; though.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.richard-slater.co.uk/archives/2010/02/27/onenote-vs-evernote/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Login failed for user &#8221;</title>
		<link>http://www.richard-slater.co.uk/archives/2010/01/25/login-failed-for-user/</link>
		<comments>http://www.richard-slater.co.uk/archives/2010/01/25/login-failed-for-user/#comments</comments>
		<pubDate>Mon, 25 Jan 2010 13:51:41 +0000</pubDate>
		<dc:creator>Richard Slater</dc:creator>
				<category><![CDATA[Sys. Admin.]]></category>
		<category><![CDATA[Things You Find]]></category>

		<guid isPermaLink="false">http://www.richard-slater.co.uk/?p=724</guid>
		<description><![CDATA[There is an excellent post on the SQL Protocols blog about diagnosing the “Login failed for user &#8221;. The user is not associated with a trusted SQL Server connection.” message displayed by SQL Management Studio and other applications which use the same API; Notice the blank username &#8221;.
I believe there is one possibility missing from [...]]]></description>
			<content:encoded><![CDATA[<p>There is an <a href="http://blogs.msdn.com/sql_protocols/archive/2008/05/03/understanding-the-error-message-login-failed-for-user-the-user-is-not-associated-with-a-trusted-sql-server-connection.aspx">excellent post</a> on the SQL Protocols blog about diagnosing the <em>“Login failed for user &#8221;. The user is not associated with a trusted SQL Server connection.”</em> message displayed by SQL Management Studio and other applications which use the same API; Notice the blank username &#8221;.</p>
<p>I believe there is one possibility missing from the above post: that is the Group Policy setting &#8220;Deny access to this computer from the network&#8221;. Which can be found in both Domain Group Policy and Local Security Policy in the following path:</p>
<p><em>Computer Configuration » Windows Settings » Security Settings » Local Policies » User Rights Assignment.</em></p>
<p>I have been using this policy more and more to lockdown access to site systems in accordance with our security and access policy. It pays to be cautious when applying User Rights Assignment policies to a machine, as in Windows 2003/XP they are not very granular.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.richard-slater.co.uk/archives/2010/01/25/login-failed-for-user/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Christmas Cake</title>
		<link>http://www.richard-slater.co.uk/archives/2009/12/30/christmas-cake/</link>
		<comments>http://www.richard-slater.co.uk/archives/2009/12/30/christmas-cake/#comments</comments>
		<pubDate>Wed, 30 Dec 2009 10:11:49 +0000</pubDate>
		<dc:creator>Richard Slater</dc:creator>
				<category><![CDATA[Diary]]></category>

		<guid isPermaLink="false">http://www.richard-slater.co.uk/?p=721</guid>
		<description><![CDATA[We often get a bit of my mum&#8217;s Christmas cake each year, this year we got given a whole (albeit mini) cake. Whole lot of other treats in a gift bag. Got to be one of my favourite Christmas Presents this year.

]]></description>
			<content:encoded><![CDATA[<p>We often get a bit of my mum&#8217;s Christmas cake each year, this year we got given a whole (albeit mini) cake. Whole lot of other treats in a gift bag. Got to be one of my favourite Christmas Presents this year.</p>
<p style="text-align: center;"><a href="http://www.richard-slater.co.uk/wp-content/uploads/2009/12/ChristmasCake2009.jpg"><img class="aligncenter size-medium wp-image-722" title="Christmas Cake 2009" src="http://www.richard-slater.co.uk/wp-content/uploads/2009/12/ChristmasCake2009-300x300.jpg" alt="Christmas Cake 2009" width="300" height="300" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.richard-slater.co.uk/archives/2009/12/30/christmas-cake/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Debugging &#8220;Just My Code&#8221;</title>
		<link>http://www.richard-slater.co.uk/archives/2009/12/05/debugging-just-my-code/</link>
		<comments>http://www.richard-slater.co.uk/archives/2009/12/05/debugging-just-my-code/#comments</comments>
		<pubDate>Sat, 05 Dec 2009 15:59:19 +0000</pubDate>
		<dc:creator>Richard Slater</dc:creator>
				<category><![CDATA[EVE Online]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.richard-slater.co.uk/?p=714</guid>
		<description><![CDATA[Within EVEMon we have started making heavy use of LINQBridge which uses Visual Studio 2008&#8217;s Multi-Targeting capabilities to allow a .NET 2.0 applications to use the compiler functionality of C# 3.0. This reduces our need to push EVEMon towards .NET 3.5, and simplifies our dependency stack for the end user (.NET 2.0 is pre-installed on [...]]]></description>
			<content:encoded><![CDATA[<p>Within <a href="http://evemon.battleclinic.com/">EVEMon</a> we have started making heavy use of <a href="http://www.albahari.com/nutshell/linqbridge.aspx">LINQBridge</a> which uses Visual Studio 2008&#8217;s <a href="http://weblogs.asp.net/scottgu/archive/2007/06/20/vs-2008-multi-targeting-support.aspx">Multi-Targeting capabilities</a> to allow a .NET 2.0 applications to use the compiler functionality of C# 3.0. This reduces our need to push EVEMon towards .NET 3.5, and simplifies our dependency stack for the end user (.NET 2.0 is pre-installed on Vista and above, .NET 3.5 is pre-installed in Windows 7 and above).</p>
<p>One of the annoyances I have run into is every time there is a problem with a LINQ statement the debugger will stop in the LINQBridge project rather than EVEMon&#8217;s code; this usually tells you nothing useful forcing you to dig into the exception to find the stack trace to find out which line caused the exception.</p>
<p>I <a href="http://blogs.msdn.com/jmstall/archive/2004/12/31/344832.aspx">found</a> a natty attribute in <a href="http://msdn.microsoft.com/en-us/library/system.diagnostics.debuggernonusercodeattribute.aspx">DebuggerNonUserCode</a> that allows you to tell the debugger to treat a class as Non-User Code:</p>

<div class="wp_syntax"><div class="code"><pre class="csharp" style="font-family:monospace;"><span style="color: #000000;">&#91;</span><span style="color: #000000;">System.<span style="color: #0000FF;">Diagnostics</span></span>.<span style="color: #0000FF;">DebuggerNonUserCode</span><span style="color: #000000;">&#93;</span></pre></div></div>

<p>So far, I have not found a disadvantage in doing this. I am being conservative with my use in case I find some glaring problem, however LINQBridge has proven a stable project, and quite frankly I would much rather be looking at my own broken code when something goes wrong, rather than LINQBridges working code.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.richard-slater.co.uk/archives/2009/12/05/debugging-just-my-code/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Controling Code Outlining with the Keyboard</title>
		<link>http://www.richard-slater.co.uk/archives/2009/11/03/controling-code-outlining-with-the-keyboard/</link>
		<comments>http://www.richard-slater.co.uk/archives/2009/11/03/controling-code-outlining-with-the-keyboard/#comments</comments>
		<pubDate>Tue, 03 Nov 2009 19:13:35 +0000</pubDate>
		<dc:creator>Richard Slater</dc:creator>
				<category><![CDATA[CodeRush]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[C#]]></category>
		<category><![CDATA[Visual Studio]]></category>

		<guid isPermaLink="false">http://www.richard-slater.co.uk/?p=702</guid>
		<description><![CDATA[Code outlining is a feature of supported by Visual Studio and many other editors, MSDN has some good documentation for VS2005, VS2008 and VS2010. If I were asked to explain this as briefly as possible, I would probably say:
Code Outlining is the logical partitioning of code in such a way that the user interface, or [...]]]></description>
			<content:encoded><![CDATA[<p>Code outlining is a feature of supported by Visual Studio and many other editors, MSDN has some good documentation for <a href="http://msdn.microsoft.com/en-us/library/td6a5x4s(VS.80).aspx">VS2005</a>, <a href="http://msdn.microsoft.com/en-us/library/td6a5x4s.aspx">VS2008 </a>and <a href="http://msdn.microsoft.com/en-us/library/td6a5x4s(VS.100).aspx">VS2010</a>. If I were asked to explain this as briefly as possible, I would probably say:</p>
<blockquote><p>Code Outlining is the logical partitioning of code in such a way that the user interface, or editor, is able to selectively hide the body of the content (such as a class, struct, enum or method) whilst leaving the signature or some identifying comment visible.</p></blockquote>
<p>You can see this in action in Visual Studio 2008 with the following Screenshot:</p>
<p><img class="alignnone size-full wp-image-705" title="CodeOutliningVS2008" src="http://www.richard-slater.co.uk/wp-content/uploads/2009/11/CodeOutliningVS2008.png" alt="CodeOutliningVS2008" width="500" height="295" /></p>
<p>I accidentally turned off Code Outlining today by hitting some keyboard shortcut that I didn&#8217;t know how to reverse, this lead me to discover several useful keyboard shortcuts for managing the display of your code from the keyboard.</p>
<p>As it turns out I managed to hit Ctrl-M followed by Ctrl-P (or just P in fact) which maps to Edit.StopOutlining, by default it seems that the Visual C# 2005 mapping scheme doesn&#8217;t provide a shortcut to enable Automatic Outlining so instead you can access the command through Edit Menu -&gt; Outlining -&gt; Start Automatic Outlining.</p>
<p>Enabled again, I get to play with code outlining from the keyboard:</p>
<ul>
<li>To toggle (collapse an expanded block or expand a collapsed block) the closest outlined element use Ctrl-M followed by Ctrl-M.</li>
<li>To toggle everything use Ctrl-M followed by Ctrl-L (I find little use for this)</li>
<li>To collapse to definitions use Ctrl-M followed by Ctrl-O</li>
</ul>
<p>The last one is the most useful when used in conjunction with <a href="http://msdn.microsoft.com/en-us/library/9a1ybwek.aspx">Regions</a> as after colapsing to definitions you will get something similar to this:</p>
<p><img class="alignnone size-full wp-image-706" title="ColapseToDefinitionsVS2008" src="http://www.richard-slater.co.uk/wp-content/uploads/2009/11/ColapseToDefinitionsVS2008.png" alt="ColapseToDefinitionsVS2008" width="555" height="389" /></p>
<p>You might have noticed in the first screenshot that CodeRush Xpress adds a coloured line between the beginning and end of blocks of code, this is a nice feature if you have long blocks of code, which of course you shouldn&#8217;t have.</p>
<p><img class="alignnone size-full wp-image-707" title="CodeRushXpressBlockLines" src="http://www.richard-slater.co.uk/wp-content/uploads/2009/11/CodeRushXpressBlockLines.png" alt="CodeRushXpressBlockLines" width="70" height="107" /></p>
<p>There we go, an errant key stroke can lead to learning and blogging, who would have thought it?</p>
]]></content:encoded>
			<wfw:commentRss>http://www.richard-slater.co.uk/archives/2009/11/03/controling-code-outlining-with-the-keyboard/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Card Reader on Acer Aspire 5100 Series Under Windows 7</title>
		<link>http://www.richard-slater.co.uk/archives/2009/10/26/card-reader-on-acer-aspire-5100-serie-under-windows-7/</link>
		<comments>http://www.richard-slater.co.uk/archives/2009/10/26/card-reader-on-acer-aspire-5100-serie-under-windows-7/#comments</comments>
		<pubDate>Mon, 26 Oct 2009 20:24:56 +0000</pubDate>
		<dc:creator>Richard Slater</dc:creator>
				<category><![CDATA[Sys. Admin.]]></category>
		<category><![CDATA[Driver]]></category>
		<category><![CDATA[Laptop]]></category>

		<guid isPermaLink="false">http://www.richard-slater.co.uk/?p=693</guid>
		<description><![CDATA[Important Update (16/11/2009): there seems to be a problem with these drivers causing a crash. I am going to experiment further with this laptop and try and diagnose the cause of the problem and hopefully find a solution.
I am typing this on my Acer Aspire 5102WLMi which is one of the popular (if flawed) Acer [...]]]></description>
			<content:encoded><![CDATA[<p><span style="color: #ff0000;"><strong>Important Update (16/11/2009): there seems to be a problem with these drivers causing a crash. I am going to experiment further with this laptop and try and diagnose the cause of the problem and hopefully find a solution.</strong></span></p>
<p>I am typing this on my Acer Aspire 5102WLMi which is one of the popular (if flawed) Acer Aspire 5100 series; I rescued this one from the Balconi Test by putting a bit of rubber (it was a cut down rubber foot) on top of the <a class='wikipedia' href='http://en.wikipedia.org/wiki/Southbridge_%28computing%29' title='Wikipedia article on Southbridge_(computing)'>South Bridge</a> chip set, that however is not the story I am telling today.</p>
<p>I never bothered to install the Card Reader driver on this laptop while I was running the Windows 7 Beta, mainly because I am lazy, but also I didn&#8217;t have a need for it so it never came up. With the release of Windows 7 I wanted to get the system perfect, seeing as hopefully it will last a good year in it&#8217;s present state, and I wanted to be able to re-arrange the SD card from my Acer PDA.</p>
<p>Windows 7 x64 was unable to identify a driver for this particular card reader, this left me with three unknown devices in Device Manager:</p>
<p><img class="alignnone size-full wp-image-696" title="Missing Drivers Acer 5100" src="http://www.richard-slater.co.uk/wp-content/uploads/2009/10/MissingDriversAcer5100.png" alt="Missing Drivers Acer 5100" width="215" height="94" /></p>
<p>The Acer website was a bust, as far as Acer are concerned this laptop won&#8217;t even run Vista x64, so I had to dig deeper. From past experience of looking for drivers without using Windows Update I knew that I could probably identify the manufacturer from the Hardware and Device ID&#8217;s available through Device Manager. If you want to follow along here are the steps:</p>
<ol>
<li>Open up Device Manager (Right Click &#8220;Computer&#8221;, Choose &#8220;Manage&#8221;, Select &#8220;Device Manager&#8221;)</li>
<li>Identify your unknown devices (They will look similar to the image above, although the text will differ)</li>
<li>Right click one of them and select &#8220;Properties&#8221;</li>
<li>Switch to the &#8220;Details&#8221; tab</li>
<li>Change the property drop down box to read &#8220;Hardware Ids&#8221;</li>
</ol>
<p>What that will give you is one or more strings looking something like this</p>
<pre>PCI\VEN_<strong>1524</strong>&amp;DEV_<strong>0530</strong>&amp;SUBSYS_009F1025&amp;REV_01</pre>
<p>I have marked the two important parts in bold, the four digits after &#8220;VEN_&#8221; tell you the <a class='wikipedia' href='http://en.wikipedia.org/wiki/Conventional_PCI' title='Wikipedia article on Conventional_PCI'>PCI</a> Vendor number, the four digits after &#8220;DEV_&#8221; tells you device number these two numbers should uniquely identify the driver.</p>
<p>There are several sites that allow you to lookup these numbers, I tend to use the publicly available PCI Vendor and Device Lists at <a href="http://www.pcidatabase.com/">PCIDatabase.com</a>. Which has always given me good results with minimum fuss and adverts.</p>
<p>Armed with the above I identified the manufacturer of the Card Reader was ENE Technologies, sometimes this is all you need to find the driver. You can Google/Bing the name and click the download or support links and get the latest drivers. This isn&#8217;t always the way, as some <a class='wikipedia' href='http://en.wikipedia.org/wiki/Original_equipment_manufacturer' title='Wikipedia article on Original_equipment_manufacturer'>OEMs</a> don&#8217;t offer drivers leaving that down to the system integrator to offer that service.</p>
<p>So some time with Bing, I found some drivers for various ENE Devices, however the drivers available from <a href="http://www.versiontracker.com/dyn/moreinfo/win/115639">VersionTracker</a> seemed promising. After downloading and unzipping the contents of the file to a folder on my Desktop, I was able to point Device Manager at these files for each of the unknown devices I was left with three working devices and a fully operational Card Reader.</p>
<p><img class="alignnone size-full wp-image-695" title="ENECardReaderDriversAcer5100" src="http://www.richard-slater.co.uk/wp-content/uploads/2009/10/ENECardReaderDriversAcer5100.png" alt="ENECardReaderDriversAcer5100" width="386" height="113" /></p>
<p>Hope this helps some other people with similar laptops or Card Readers, post in the comments with your experiences, please include the manufacturer and model of the laptop/netbook you have succeeded with and hopefully you will help someone else with the same devices.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.richard-slater.co.uk/archives/2009/10/26/card-reader-on-acer-aspire-5100-serie-under-windows-7/feed/</wfw:commentRss>
		<slash:comments>26</slash:comments>
		</item>
		<item>
		<title>Change your MTU under Vista or Windows 7</title>
		<link>http://www.richard-slater.co.uk/archives/2009/10/23/change-your-mtu-under-vista-or-windows-7/</link>
		<comments>http://www.richard-slater.co.uk/archives/2009/10/23/change-your-mtu-under-vista-or-windows-7/#comments</comments>
		<pubDate>Fri, 23 Oct 2009 20:11:31 +0000</pubDate>
		<dc:creator>Richard Slater</dc:creator>
				<category><![CDATA[Sys. Admin.]]></category>
		<category><![CDATA[Netsh]]></category>
		<category><![CDATA[TCP/IP]]></category>
		<category><![CDATA[Windows]]></category>
		<category><![CDATA[Windows 7]]></category>
		<category><![CDATA[Windows Vista]]></category>

		<guid isPermaLink="false">http://www.richard-slater.co.uk/?p=683</guid>
		<description><![CDATA[This information is available in many many other places, however I am putting it on here because I know it will be here for me to refer to. Also it is handy, as I know I can access my web-site even if the MTU is misconfigured.
For some reason that has escaped me Path MTU Discovery [...]]]></description>
			<content:encoded><![CDATA[<p><em>This information is available in many many other places, however I am putting it on here because I know it will be here for me to refer to. Also it is handy, as I know I can access my web-site even if the <a class='wikipedia' href='http://en.wikipedia.org/wiki/Maximum_transmission_unit' title='Wikipedia article on Maximum_transmission_unit'>MTU</a> is misconfigured.</em></p>
<p>For some reason that has escaped me <a class='wikipedia' href='http://en.wikipedia.org/wiki/Path_MTU_discovery' title='Wikipedia article on Path_MTU_discovery'>Path MTU Discovery</a> in Windows just doesn&#8217;t seem to figure out the MTU for a given path (something to do with routers being poorly configured to not respond to <a class='wikipedia' href='http://en.wikipedia.org/wiki/Internet_Control_Message_Protocol' title='Wikipedia article on Internet_Control_Message_Protocol'>ICMP</a> requests). So Windows uses the default. For the most part this doesn&#8217;t affect anyone, however if it dos affect you, it really annoys you. Failure of PMTUD will result in some websites not loading correctly, having trouble connecting to normally reliable online services and general Internet weirdness.</p>
<p>The resolution is to set your default MTU to one lower than the <a class='wikipedia' href='http://en.wikipedia.org/wiki/Ethernet' title='Wikipedia article on Ethernet'>Ethernet</a> default of 1500. Here is how:</p>
<p><strong>Step 1: Find your MTU</strong><br />
From an elevated CMD Shell enter the following command:</p>

<div class="wp_syntax"><div class="code"><pre class="dos" style="font-family:monospace;">netsh interface ipv4 show subinterfaces</pre></div></div>

<p>You should get something like this</p>
<pre>MTU         MediaSenseState  Bytes In    Bytes Out  Interface
----------  ---------------  ---------   ---------  -------------
4294967295  1                0           13487914   Loopback Pseudo-Interface 1
1500        1                3734493902  282497358  Local Area Connection</pre>
<p>If you are using Ethernet cable you will be looking for &#8220;Local Area Connection&#8221; or &#8220;Local Area Connection 2&#8243; (if you happened to plug into the second network port). If you are using Wireless you will be looking for &#8220;Wireless Network Connection&#8221;. The MTU is in the first column.</p>
<p><strong>Step 2: Find out what it should be</strong></p>
<p>In the CMD shell type:</p>

<div class="wp_syntax"><div class="code"><pre class="dos" style="font-family:monospace;">ping www.cantreachthissite.com -f -l <span style="color: #cc66cc;">1472</span></pre></div></div>

<p>The host name should be a site you <span style="text-decoration: underline;"><strong>can not</strong></span> reach, -f marks the packet as one that should not be fragmented the -l 1472 sets the size of the packet (1472 = Ethernet Default MTU &#8211; Packet Header, where the Ethernet Default MTU is 1500 and the Packet Header is 28 bytes)</p>
<p>If the packet can&#8217;t be sent because it would need to be fragmented you will get something similar to this:</p>
<pre>Packet needs to be fragmented but DF set.</pre>
<p>Keep trying lower packet sizes by 10 (i.e. -l 1460, 1450, 1440, etc.) until you get a successful ping request. Raise your packet sizes by one until you get a &#8220;Packet needs to be fragmented but DF set.&#8221;. The last successful value plus 28 will be your MTU value.</p>
<p>In my case a packet size of 1430 succeeds but 1431 fails, so 1430 + 28 = 1458.</p>
<p><strong>Step 3: Set your MTU</strong></p>
<p>Now you have identified the interface you need to change and the ideal MTU for you, now it is time to make the change. Again from an elevated CMD Shell type the following replacing my MTU of 1458 with your own value:</p>

<div class="wp_syntax"><div class="code"><pre class="dos" style="font-family:monospace;">netsh interface ipv4 <span style="color: #b1b100; font-weight: bold;">set</span> <span style="color: #448844;">subinterface &quot;Local Area Connection&quot; mtu</span>=<span style="color: #cc66cc;">1458</span> store=persistent</pre></div></div>

<p>Or if you are using a Wireless connection:</p>

<div class="wp_syntax"><div class="code"><pre class="dos" style="font-family:monospace;">netsh interface ipv4 <span style="color: #b1b100; font-weight: bold;">set</span> <span style="color: #448844;">subinterface &quot;Wireless Network Connection&quot; mtu</span>=<span style="color: #cc66cc;">1458</span> store=persistent</pre></div></div>

<p>If all has gone well you should have a perfectly working internet connection.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.richard-slater.co.uk/archives/2009/10/23/change-your-mtu-under-vista-or-windows-7/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>
