<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss 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/" version="2.0">

<channel>
	<title>muonlab</title>
	
	<link>http://blog.muonlab.com</link>
	<description>random .NET and web development musings</description>
	<lastBuildDate>Wed, 01 Feb 2012 19:32:58 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/Muonlab" /><feedburner:info xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" uri="muonlab" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>Min width table cell in 100% width table</title>
		<link>http://blog.muonlab.com/2012/02/01/min-width-table-cell-in-100-width-table/</link>
		<comments>http://blog.muonlab.com/2012/02/01/min-width-table-cell-in-100-width-table/#comments</comments>
		<pubDate>Wed, 01 Feb 2012 19:32:58 +0000</pubDate>
		<dc:creator>Andrew Bullock</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[CSS]]></category>

		<guid isPermaLink="false">http://blog.muonlab.com/?p=452</guid>
		<description><![CDATA[If you make a table 100% width: table { width: 100% } then you&#8217;ll find that the cells within it will arrange themselves so they have a width proportional their respective content lengths. However, sometimes you might want to have cell be as narrow as possible, and fit itself down to its contents, and let [...]]]></description>
			<content:encoded><![CDATA[<p>If you make a table 100% width:</p>
<pre class="brush: css">
table {
    width: 100%
}
</pre>
<p>then you&#8217;ll find that the cells within it will arrange themselves so they have a width proportional their respective content lengths. However, sometimes you might want to have cell be as narrow as possible, and fit itself down to its contents, and let the others auto width themselves.</p>
<p>One options is to give the cell in question a fixed width, but this isnt a flexible solution if the width needs to vary.</p>
<p>Step up the following:</p>
<pre class="brush: css">
table {
    width 100%;
}
table td.narrow {
    width: 1px;
    white-space: nowrap;
}
</pre>
<p>the width on the cell will make it behave like the min-width property, it will be at least 1px wide, larger content will cause it to expand. Brilliant! Then add a cheeky nowrap to prevent it from wrapping at whitespace and you&#8217;re away!</p>
<p>Aceness</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.muonlab.com/2012/02/01/min-width-table-cell-in-100-width-table/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Chrome extension to fix Twitter redesign</title>
		<link>http://blog.muonlab.com/2012/01/15/chrome-extension-to-fix-twitter-redesign/</link>
		<comments>http://blog.muonlab.com/2012/01/15/chrome-extension-to-fix-twitter-redesign/#comments</comments>
		<pubDate>Sun, 15 Jan 2012 13:51:05 +0000</pubDate>
		<dc:creator>Andrew Bullock</dc:creator>
				<category><![CDATA[javascript]]></category>

		<guid isPermaLink="false">http://blog.muonlab.com/?p=444</guid>
		<description><![CDATA[Annoyed to death that Twitter have swapped the column order round on their site so the content is on the right, I&#8217;ve made an extension for Chrome that fixes it. Here&#8217;s how to do it. Make a folder somewhere, and inside it create a file called &#8220;manifest.json&#8221;. Put this inside it: { "name": "Fix Twitter [...]]]></description>
			<content:encoded><![CDATA[<p>Annoyed to death that Twitter have swapped the column order round on their site so the content is on the right, I&#8217;ve made an extension for Chrome that fixes it.</p>
<p>Here&#8217;s how to do it.</p>
<p>Make a folder somewhere, and inside it create a file called &#8220;manifest.json&#8221;. Put this inside it:</p>
<pre class="brush: javascript">
{
	"name": "Fix Twitter Columns Order"
	, "version": "0.1"
	, "description": "Switches the Twitter columns around so content is on the left"
	, "content_scripts": [
		{
			"matches": ["https://twitter.com/*", "http://twitter.com/*"]
			, "css": ["style.css"]
		}
	]
}
</pre>
<p>Then create a file called &#8220;style.css&#8221; and put this inside it:</p>
<pre class="brush: css">
.content-main
{
	float: left !important;
}

.dashboard
{
	float: right !important;
}
</pre>
<p>And there we go!</p>
<p>Goto Chrome -> Tools -> Extensions.</p>
<p>Tick &#8220;Developer Mode&#8221;, then click &#8220;Load unpacked extension&#8221; and navigate to the folder you created the json and css in.</p>
<p>Done! You can download the source <a href='http://blog.muonlab.com/wp-content/uploads/2012/01/FixTwitterStyle.zip'>here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.muonlab.com/2012/01/15/chrome-extension-to-fix-twitter-redesign/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Simplistic Canonical Linking in ASP.NET MVC</title>
		<link>http://blog.muonlab.com/2011/11/27/simplistic-canonical-linking-in-asp-net-mvc/</link>
		<comments>http://blog.muonlab.com/2011/11/27/simplistic-canonical-linking-in-asp-net-mvc/#comments</comments>
		<pubDate>Sun, 27 Nov 2011 11:36:43 +0000</pubDate>
		<dc:creator>Andrew Bullock</dc:creator>
				<category><![CDATA[ASP.Net]]></category>
		<category><![CDATA[MVC]]></category>

		<guid isPermaLink="false">http://blog.muonlab.com/?p=438</guid>
		<description><![CDATA[I wanted a simple way to manage canonical links in ASP.NET MVC. It would have been nice to work these out automatically from the route tables, but for the project I am working on, its far too convoluted to be done easily, I&#8217;d rather maintain a fixed definition for each action. Step up a custom [...]]]></description>
			<content:encoded><![CDATA[<p>I wanted a simple way to manage canonical links in ASP.NET MVC.</p>
<p>It would have been nice to work these out automatically from the route tables, but for the project I am working on, its far too convoluted to be done easily, I&#8217;d rather maintain a fixed definition for each action.</p>
<p>Step up a custom `ActionFilterAttribute`:</p>
<pre class="brush: csharp;">
[AttributeUsage(AttributeTargets.Method, AllowMultiple = false, Inherited = false)]
public sealed class CanonicalUrl : ActionFilterAttribute
{
	readonly string url;

	public CanonicalUrl(string url)
	{
		this.url = url;
	}

	public override void OnResultExecuting(ResultExecutingContext filterContext)
	{
		var uri = filterContext.RequestContext.HttpContext.Request.Url;
		var fullyQualifiedUrl = (uri.Scheme + "://" + uri.Host + this.url).ToLowerInvariant();

		foreach (var key in filterContext.RouteData.Values.Keys)
			fullyQualifiedUrl = fullyQualifiedUrl.Replace("{" + key.ToLowerInvariant() + "}",
															filterContext.RouteData.Values[key].ToString());

		filterContext.Controller.ViewData["CanonicalUrl"] = fullyQualifiedUrl;
		filterContext.HttpContext.Response.Headers.Add("link", "&lt;" + fullyQualifiedUrl + "&gt;; rel=\"canonical\"");

		base.OnResultExecuting(filterContext);
	}
}
</pre>
<p>You can then decorate your actions like this:</p>
<pre class="brush: csharp;">
[CanonicalUrl("/show/{name}")]
[AcceptVerbs(HttpVerbs.Get)]
public ActionResult Show(string name)
</pre>
<p>Make sure you stick the link element in your page&#8217;s head:</p>
<pre class="brush: csharp;">
<% if(ViewData["CanonicalUrl"] != null){ %>
	&lt;link rel="canonical" href="&lt;%: ViewData["CanonicalUrl"] %&gt;" /&gt;
<%} %>
</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.muonlab.com/2011/11/27/simplistic-canonical-linking-in-asp-net-mvc/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Casting an enumerable when the inner type is only known at runtime</title>
		<link>http://blog.muonlab.com/2011/10/07/casting-an-enumerable-when-the-inner-type-is-only-known-at-runtime/</link>
		<comments>http://blog.muonlab.com/2011/10/07/casting-an-enumerable-when-the-inner-type-is-only-known-at-runtime/#comments</comments>
		<pubDate>Fri, 07 Oct 2011 19:19:51 +0000</pubDate>
		<dc:creator>Andrew Bullock</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.muonlab.com/?p=434</guid>
		<description><![CDATA[If you want to cast an Enumerable&#8217;s inner type, you can use LINQ: var casted = myEnumerable.Cast&#60;int&#62;(); But what when you only know the inner type (int) at runtime? The easiest way is the following reflection magic: public static IEnumerable Cast(this IEnumerable self, Type innerType) { var methodInfo = typeof (Enumerable).GetMethod("Cast"); var genericMethod = methodInfo.MakeGenericMethod(innerType); [...]]]></description>
			<content:encoded><![CDATA[<p>If you want to cast an Enumerable&#8217;s inner type, you can use LINQ:</p>
<pre class="brush: csharp;">
var casted = myEnumerable.Cast&lt;int&gt;();
</pre>
<p>But what when you only know the inner type (int) at runtime?</p>
<p>The easiest way is the following reflection magic:</p>
<pre class="brush: csharp;">
public static IEnumerable Cast(this IEnumerable self, Type innerType)
{
	var methodInfo = typeof (Enumerable).GetMethod("Cast");
	var genericMethod = methodInfo.MakeGenericMethod(innerType);
	return genericMethod.Invoke(null, new [] {self}) as IEnumerable;
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.muonlab.com/2011/10/07/casting-an-enumerable-when-the-inner-type-is-only-known-at-runtime/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A technique for precompiling and embedding MVC views</title>
		<link>http://blog.muonlab.com/2011/09/06/a-technique-for-precompiling-and-embedding-mvc-views/</link>
		<comments>http://blog.muonlab.com/2011/09/06/a-technique-for-precompiling-and-embedding-mvc-views/#comments</comments>
		<pubDate>Tue, 06 Sep 2011 14:20:40 +0000</pubDate>
		<dc:creator>Andrew Bullock</dc:creator>
				<category><![CDATA[ASP.Net]]></category>
		<category><![CDATA[MVC]]></category>

		<guid isPermaLink="false">http://blog.muonlab.com/?p=417</guid>
		<description><![CDATA[I&#8217;ve used two approaches to &#8220;embedding&#8221; the ascx views, one thats quite simple, and one thats a bit more complicated and needs quite a lot of explanation as to why I&#8217;m doing it that way. The easiest way to do it is to embed the ascx file, and access it with a Custom VirtualPathProvider. This [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve used two approaches to &#8220;embedding&#8221; the ascx views, one thats quite simple, and one thats a bit more complicated and needs quite a lot of explanation as to why I&#8217;m doing it that way.</p>
<p>The easiest way to do it is to embed the ascx file, and access it with a <a href="http://www.wynia.org/wordpress/2008/12/aspnet-mvc-plugins/" title="Custom VirtualPathProvider">Custom VirtualPathProvider</a>.</p>
<p>This approach however suffers several drawbacks. </p>
<p>The first problem comes at dev time. You have to rebuild every time you change the ascx. This might not be a problem for you, but in large projects it can add several seconds delay to every change you make, which for someone whos trying to be productive, can be very annoying.</p>
<p>The easiest solution to this is to modify the custom VirtualPathProvider above so that it is aware whether it is in dev or production mode. I do this with the debug attribute in the web config:</p>
<pre class="brush: csharp;">
public bool AreInDevMode
{
	get
	{
		var section = ConfigurationManager.GetSection("system.web/compilation") as CompilationSection;
		return section.Debug;
	}
}
</pre>
<p>Then, when you&#8217;re in dev mode, check the file system before checking for the embedded resource. This will perhaps involve some path hackery, but generally I&#8217;m ok with this because the path conventions in my projects are consistent.</p>
<p>The second problem with this method is that the view is essentially embedded as a string, the text that makes up the view ascx. This means the view has to be compiled at runtime. This has two issues:</p>
<p>a) its slow, especially when you have many views<br />
b) you dont get build time compilation error checking.</p>
<p>So how do we solve this? </p>
<p>To compile the views, you need the <a href="http://msdn.microsoft.com/en-us/library/ms229863.aspx">ASP.NET Precompilation tool</a>.</p>
<p>This will create a separate assembly for each compiled view. This is messy, so we can merge them together using the <a href="http://msdn.microsoft.com/en-us/library/bb397866.aspx">ASP.NET Merge tool</a>.</p>
<p>Getting better, but you still have two assemblies, your main project code and the one with the views in. <a href="http://research.microsoft.com/en-us/people/mbarnett/ilmerge.aspx">ILMerge </a>to the rescue. However, before we do that I want to sort out the compiled view types.</p>
<p>If you open a precompiled view dll in reflector, you&#8217;ll find its rather messy and things aren&#8217;t named very nicely. For example, say your project has the following views:</p>
<pre>
/Plugins/PluginA/View-A.ascx
/Plugins/PluginB/View.ascx
</pre>
<p>You&#8217;ll end up with the following types:</p>
<pre>
plugins_plugina_view_a_ascx
plugins_pluginb_view_ascx
</pre>
<p>So, what I wan&#8217;t to do is put them back into the correct namespace. Unfortunately, because certain characters that are allowed in file paths are not allowed in namespaces, these chars get converted to underscores and you therefore can&#8217;t work out the namespace you need from the compiled type name alone. (e.g. you dont know if &#8220;<code>path_to_some_view_ascx</code>&#8221; was originally &#8220;<code>path/to/some/view.ascx</code>&#8221; or &#8220;<code>path/to-some.view.ascx</code>&#8220;)</p>
<p>Therefore I iterate over the file system and look for any <code>.ascx</code>, <code>.aspx</code> and <code>.master</code> files, turn their paths into their corresponding type names. I then have a lookup table of the type name and its original path.</p>
<p>THEN I can <a href="http://blog.muonlab.com/2011/08/01/how-to-modify-net-types-names-and-namespaces-inside-compiled-assemblies-using-mono-cecil/">use Mono.Cecil to alter the type names</a>.</p>
<p>so for the file:</p>
<p><code>/Plugins/PluginA/View.ascx</code></p>
<p>I calculate its type name:</p>
<p><code>plugins_plugina_view_ascx</code></p>
<p>and the name(space) I want it to have:</p>
<p><code>Plugins.PluginA.View</code></p>
<p>Do this for all the views and then I can ILMerge my two assemblies into one, nicely organised final package <img src='http://blog.muonlab.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
<p>So how do you then get MVC to render the view?</p>
<p>First you need to extend WebFormsViewEngine, and override:</p>
<pre class="brush: csharp;">
protected override IView CreatePartialView(ControllerContext controllerContext, string partialPath) {
    return new WebFormView(partialPath, null);
}

protected override IView CreateView(ControllerContext controllerContext, string viewPath, string masterPath) {
    return new WebFormView(viewPath, masterPath);
}
</pre>
<p>So that it returns a custom View, which extends WebFormView and overrides Render:</p>
<pre class="brush: csharp;">
public virtual void Render(ViewContext viewContext, TextWriter writer)
</pre>
<p>so that instead of creating the view using the BuildManager, it simply instantiates the type you worked out above.</p>
<p>If you followed any of that, well done!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.muonlab.com/2011/09/06/a-technique-for-precompiling-and-embedding-mvc-views/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>A technique for packaging UI plugins in ASP.NET MVC part 1</title>
		<link>http://blog.muonlab.com/2011/09/06/a-technique-for-packaging-ui-plugins-in-asp-net-mvc-part-1/</link>
		<comments>http://blog.muonlab.com/2011/09/06/a-technique-for-packaging-ui-plugins-in-asp-net-mvc-part-1/#comments</comments>
		<pubDate>Tue, 06 Sep 2011 13:01:39 +0000</pubDate>
		<dc:creator>Andrew Bullock</dc:creator>
				<category><![CDATA[ASP.Net]]></category>
		<category><![CDATA[MVC]]></category>

		<guid isPermaLink="false">http://blog.muonlab.com/?p=399</guid>
		<description><![CDATA[In this series of posts I&#8217;m going to describe the techniques I use for supporting a plugin architecture in ASP.NET MVC. What do I mean by plugin? Well, without going into the specific details of the system I&#8217;ve developed this for (it isnt important), a &#8220;plugin&#8221; is simply a bit of UI functionality I want [...]]]></description>
			<content:encoded><![CDATA[<p>In this series of posts I&#8217;m going to describe the techniques I use for supporting a plugin architecture in ASP.NET MVC.</p>
<p>What do I mean by plugin? Well, without going into the specific details of the system I&#8217;ve developed this for (it isnt important), a &#8220;plugin&#8221; is simply a bit of UI functionality I want to encapsulate into a package that I can reuse. These plugins typically include some codebehind, a view (ascx), some javascript and some css.</p>
<p>A typical plugin will look like this:</p>
<pre>
/plugins/exampleplugin/exampleplugin.cs
/plugins/exampleplugin/exampleplugin.css
/plugins/exampleplugin/exampleplugin.js
/plugins/exampleplugin/exampleplugin.ascx
</pre>
<p>When using a plugin, I want to just drop a dll in the bin (or reference it, whatever). I don&#8217;t want to have to manually add a script tag for the js, or a link for the css, or put the ascx in some views folder. I want everything to be included in a single file, and for everything to just work &#8482;.</p>
<p>To achieve this I use several techniques:</p>
<ul>
<li>Embed the css and javascript into the assembly as resources</li>
<li>Precompile the view into the assembly</li>
<li>Use a custom virtual path provider to make debug easier, and find the files at runtime.</li>
</ul>
<p>These posts won&#8217;t go in to exact detail about how everything works and is wired together in my system (again, it isnt important and would only obscure the details). This isn&#8217;t a tutorial on how to build a plugin framework (that may be a future series of posts), but hopefully it will give you a few tips and tricks to try things out yourself.<br />
There&#8217;s lots of bits I&#8217;ll gloss over, like optimisation <img src='http://blog.muonlab.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>In this post I&#8217;ll cover embedding the css and js.</p>
<h2>Embedding JS and CSS</h2>
<p>Set the Build Action of the files (css, js) to &#8220;Embedded Resource&#8221; to embed them.</p>
<p>To get the files out of the assembly as string, you&#8217;ll need some code that looks like this:</p>
<pre class="brush: csharp;">
static string GetResource(string key)
{
    var stream = this.GetType().Assembly.GetManifestResourceStream(key);
    using (var streamReader = new StreamReader(stream))
        return streamReader.ReadToEnd();
}
</pre>
<p>One thing to note is the naming rules that apply when you embed a file. Namespace sections that begin with a number get the number prefixed with an underscores, slashes get converted to dots and dashes to underscores. For example:</p>
<p><code>/assets/css/960-grid.css</code><br />
becomes<br />
<code>.assets.css._960_grid.css</code></p>
<p>You&#8217;ll probably want some function that looks like this:</p>
<pre class="brush: csharp;">
static string GetKey(string name)
{
    // folders beginning with a number have an _ prepended.
    name = Regex.Replace(name, @"/([0-9])", "/_$1");
    // turn / to . and - to _
    return name.Replace('/', '.').Replace('-', '_');
}
</pre>
<p>OK so that&#8217;s how we can get the css and js data out of the assembly, but then what to do with it?</p>
<p>Well, you&#8217;re probably going to have multiple plugins on a page, so you will have multiple css and js to include and you&#8217;ll want to bunch all this together. If you have some underlying plugin awareness mechanism, you could just pull the files you need:</p>
<pre class="brush: csharp;">
var scripts = new StringBuilder();
var styles = new StringBuilder();
foreach (var plugin in page.Plugins)
{
    var key = plugin.GetType().FullName;
    key = GetKey(key);
    scripts.Append(GetResource(key + ".js"));
    styles.Append(GetResource(key + ".css"));
}
</pre>
<p>OR you could just get all the files in some &#8220;namespace&#8221;:</p>
<pre class="brush: csharp;">
var scripts = new StringBuilder();
var styles = new StringBuilder();
var names = this.GetType().Assembly.GetManifestResourceNames();
foreach (var name in names)
{
    if(!name.StartsWith(".Plugins"))
        continue;

    if(name.EndsWith(".js"))
        scripts.Append(GetResource(name));
    else if(name.EndsWith(".css"))
        styles.Append(GetResource(name));
}
</pre>
<p>And there you go, you can then render these two strings into your page in a script and style tag <img src='http://blog.muonlab.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<h2>Some other ideas / Variations</h2>
<p>If you don&#8217;t want to render the css and js directly into the page, you could use a script tag with a src pointing at a fake file. The fake file could be mapped to an IHttpHandler in the Web.config, or use an MVC route to a controller action.</p>
<p>For example, route: <code>/assets/scripts/plugins.js</code> to some code that does something similar to the above.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.muonlab.com/2011/09/06/a-technique-for-packaging-ui-plugins-in-asp-net-mvc-part-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>.NET 4 TransactionScope timeout is ignored if greater than machine.config maxTimeout setting</title>
		<link>http://blog.muonlab.com/2011/08/03/net-4-transactionscope-timeout-is-ignored-if-greater-than-machine-config-maxtimeout-setting/</link>
		<comments>http://blog.muonlab.com/2011/08/03/net-4-transactionscope-timeout-is-ignored-if-greater-than-machine-config-maxtimeout-setting/#comments</comments>
		<pubDate>Wed, 03 Aug 2011 13:19:21 +0000</pubDate>
		<dc:creator>Andrew Bullock</dc:creator>
				<category><![CDATA[ASP.Net]]></category>

		<guid isPermaLink="false">http://blog.muonlab.com/?p=386</guid>
		<description><![CDATA[Want to see the most unhelpful code ever written? Check out System.Transactions.TransactionManager.ValidateTimeout: internal static TimeSpan ValidateTimeout(TimeSpan transactionTimeout) { if (transactionTimeout < TimeSpan.Zero) { throw new ArgumentOutOfRangeException("transactionTimeout"); } if (!(MaximumTimeout != TimeSpan.Zero) &#124;&#124; ((transactionTimeout]]></description>
			<content:encoded><![CDATA[<p>Want to see the most unhelpful code ever written?</p>
<p>Check out <code>System.Transactions.TransactionManager.ValidateTimeout</code>:</p>
<pre class="brush: csharp;">
internal static TimeSpan ValidateTimeout(TimeSpan transactionTimeout)
{
    if (transactionTimeout < TimeSpan.Zero)
    {
        throw new ArgumentOutOfRangeException("transactionTimeout");
    }
    if (!(MaximumTimeout != TimeSpan.Zero) || ((transactionTimeout <= MaximumTimeout) &#038;&#038; !(transactionTimeout == TimeSpan.Zero)))
    {
        return transactionTimeout;
    }
    return MaximumTimeout;
}
</pre>
<p>So thats saying, if you provide a timeout greater than the <code>machine.config</code> value, ignore it and use the <code>machine.config</code> one. Silently. No complaining, no warning.</p>
<p>To increase the machine.config timeout you need to add the following to machine.config (or adjust existing values if they are present):'</p>
<pre class="brush: xml;">
&lt;system.transactions&gt;
  &lt;machineSettings maxTimeout="02:00:00"/&gt;
  &lt;defaultSettings timeout="02:00:00"/&gt;
 &lt;/system.transactions&gt;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.muonlab.com/2011/08/03/net-4-transactionscope-timeout-is-ignored-if-greater-than-machine-config-maxtimeout-setting/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>How to modify .NET types’ names and namespaces inside compiled assemblies using Mono.Cecil</title>
		<link>http://blog.muonlab.com/2011/08/01/how-to-modify-net-types-names-and-namespaces-inside-compiled-assemblies-using-mono-cecil/</link>
		<comments>http://blog.muonlab.com/2011/08/01/how-to-modify-net-types-names-and-namespaces-inside-compiled-assemblies-using-mono-cecil/#comments</comments>
		<pubDate>Mon, 01 Aug 2011 12:31:52 +0000</pubDate>
		<dc:creator>Andrew Bullock</dc:creator>
				<category><![CDATA[ASP.Net]]></category>
		<category><![CDATA[Mono]]></category>

		<guid isPermaLink="false">http://blog.muonlab.com/?p=378</guid>
		<description><![CDATA[Pretty self explanatory when you know how: Updated this code to use Mono.Cecil 0.9.5.0 var assembly = AssemblyDefinition.ReadAssembly(@"path\to\assembly"); var someType = assembly.MainModule.Types.FirstOrDefault(v => v.Name == "SomeTypeName"); someType.Namespace = "I.Live.Somewhere.New"; someType.Name = "NewName"; assembly.Write(@"path\to\output");]]></description>
			<content:encoded><![CDATA[<p>Pretty self explanatory when you know how:</p>
<p><strong>Updated this code to use Mono.Cecil 0.9.5.0</strong></p>
<pre class="brush: csharp;">
var assembly = AssemblyDefinition.ReadAssembly(@"path\to\assembly");

var someType = assembly.MainModule.Types.FirstOrDefault(v => v.Name == "SomeTypeName");

someType.Namespace = "I.Live.Somewhere.New";
someType.Name = "NewName";

assembly.Write(@"path\to\output");
</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.muonlab.com/2011/08/01/how-to-modify-net-types-names-and-namespaces-inside-compiled-assemblies-using-mono-cecil/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>How to install MSDeploy (over SSL)</title>
		<link>http://blog.muonlab.com/2011/06/29/how-to-install-msdeploy-over-ssl/</link>
		<comments>http://blog.muonlab.com/2011/06/29/how-to-install-msdeploy-over-ssl/#comments</comments>
		<pubDate>Wed, 29 Jun 2011 08:33:13 +0000</pubDate>
		<dc:creator>Andrew Bullock</dc:creator>
				<category><![CDATA[Build tools]]></category>

		<guid isPermaLink="false">http://blog.muonlab.com/?p=352</guid>
		<description><![CDATA[First, download msdeploy from here: http://www.iis.net/download/WebDeploy Then install it like this: msiexec /i &#60;msi_filename&#62; /passive ADDLOCAL=ALL LISTENURL=https://+:443/MsDeployAgentService/ (you can change the port and listen path if you like, if you do, be sure to use your different port in the next step below) Then, get yourself an SSL or create a self signed one, in [...]]]></description>
			<content:encoded><![CDATA[<p>First, download msdeploy from here: <a href="http://www.iis.net/download/WebDeploy">http://www.iis.net/download/WebDeploy</a></p>
<p>Then install it like this: </p>
<p><code>msiexec /i &lt;msi_filename&gt; /passive ADDLOCAL=ALL LISTENURL=https://+:443/MsDeployAgentService/</code></p>
<p>(you can change the port and listen path if you like, if you do, be sure to use your different port in the next step below)</p>
<p>Then, get yourself an SSL or create a self signed one, in install it against MSDeploy like so:</p>
<p>Server 2003:</p>
<p><code>httpcfg set ssl -i 0.0.0.0:443 -h &lt;cert hash&gt; -g {00000000-0000-0000-0000-000000000000}</code></p>
<p>Server 2008:</p>
<p><code>netsh.exe http add sslcert ipport=0.0.0.0:443 appid={00000000-0000-0000-0000-000000000000} certhash=&lt;cert hash&gt;</code></p>
<p>To find your cert hash, either through IIS or the Certificates MMC snap-in view your cert, copy the <strong>thumbprint</strong> into notepad and remove the spaces.</p>
<p>Then, to connect to MSDeploy remotely, use the following command:</p>
<p><code>msdeploy.exe -verb:sync -source:dirPath='&lt;Some Local Path&gt;' -dest:dirPath='&lt;Some Remote Path&gt;',computername=&lt;Remote server name&gt;,userName=&lt;Remote User&gt;,password=&lt;Password&gt; -verbose</code></p>
<p>Add the <code>-allowUntrusted</code> switch if you are using a self signed SSL.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.muonlab.com/2011/06/29/how-to-install-msdeploy-over-ssl/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to return content with a 503 from ASP.NET</title>
		<link>http://blog.muonlab.com/2010/09/27/how-to-return-content-with-a-503-from-asp-net/</link>
		<comments>http://blog.muonlab.com/2010/09/27/how-to-return-content-with-a-503-from-asp-net/#comments</comments>
		<pubDate>Mon, 27 Sep 2010 18:05:02 +0000</pubDate>
		<dc:creator>Andrew Bullock</dc:creator>
				<category><![CDATA[ASP.Net]]></category>
		<category><![CDATA[IIS]]></category>

		<guid isPermaLink="false">http://blog.muonlab.com/?p=345</guid>
		<description><![CDATA[If you do: Response.StatusCode = 503; from an ASP.NET request, you will most likely get a response that looks like this: HTTP/1.1 503 Service Unavailable Cache-Control: private Content-Type: text/html X-Powered-By: ASP.NET Date: Mon, 27 Sep 2010 17:23:20 GMT Content-Length: 27 The service is unavailable. I.E. &#8220;The service is unavailable&#8221; is the only content returned, regardless [...]]]></description>
			<content:encoded><![CDATA[<p>If you do:</p>
<pre class="brush: csharp;">
Response.StatusCode = 503;
</pre>
<p>from an ASP.NET request, you will most likely get a response that looks like this:</p>
<pre class="brush: text;">
HTTP/1.1 503 Service Unavailable
Cache-Control: private
Content-Type: text/html
X-Powered-By: ASP.NET
Date: Mon, 27 Sep 2010 17:23:20 GMT
Content-Length: 27

The service is unavailable.
</pre>
<p>I.E. &#8220;The service is unavailable&#8221; is the only content returned, regardless of what your response contained. This is because http.sys in IIS is overriding your response with default custom error behaviour. Great. Fix it like this:</p>
<pre class="brush: csharp;">
Response.StatusCode = 503;
Response.TrySkipIisCustomErrors = true;
</pre>
<p>You can then return whatever content you like <img src='http://blog.muonlab.com/wp-includes/images/smilies/icon_biggrin.gif' alt=':D' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://blog.muonlab.com/2010/09/27/how-to-return-content-with-a-503-from-asp-net/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

