<?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>Fredrik Haglund's blog &#187; AssemblyKeyFile</title>
	<atom:link href="http://blog.fredrikhaglund.se/blog/tag/assemblykeyfile/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.fredrikhaglund.se</link>
	<description>Chatter about EPiServer, ASP.NET, CSS and Web Development.</description>
	<lastBuildDate>Tue, 28 Jun 2011 13:37:32 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>How to patch/fix/hack someone else&#8217;s assembly</title>
		<link>http://blog.fredrikhaglund.se/blog/2009/02/06/how-to-patchfixhack-someone-elses-assembly/</link>
		<comments>http://blog.fredrikhaglund.se/blog/2009/02/06/how-to-patchfixhack-someone-elses-assembly/#comments</comments>
		<pubDate>Fri, 06 Feb 2009 08:00:00 +0000</pubDate>
		<dc:creator>Fredrik Haglund</dc:creator>
				<category><![CDATA[EPiServer]]></category>
		<category><![CDATA[AssemblyDelaySign]]></category>
		<category><![CDATA[AssemblyKeyFile]]></category>
		<category><![CDATA[sn.exe]]></category>
		<category><![CDATA[Strong Name Tool]]></category>

		<guid isPermaLink="false">http://blog.fredrikhaglund.se/blog/2009/02/06/how-to-patchfixhack-someone-elses-assembly/</guid>
		<description><![CDATA[Here is my recipe when I can see no workaround to a defect or other problem and want to get around it. This is not for the faint hearted and I do not recommend it for production! 1. Extract source code and patch code You need to use Roaders&#8217; Reflector to export the assembly. Right-click [...]]]></description>
			<content:encoded><![CDATA[<p>Here is my recipe when I can see no workaround to a defect or other problem and want to get around it. This is not for the faint hearted and I do not recommend it for production!</p>
<h3>1. Extract source code and patch code</h3>
<p>You need to use <a href="http://www.red-gate.com/products/reflector/" target="_blank">Roaders&#8217; Reflector</a> to export the assembly. Right-click on top node and select Export&#8230;</p>
<p>Then comment out offending lines, add your logging, or patch defects.</p>
<h3>2. Recompile strong-named assembly with only the public-key</h3>
<p>Extract the public key from the existing assembly with the <a href="http://msdn.microsoft.com/en-us/library/k5b5tt23.aspx" target="_blank">Strong Name Tool</a>:</p>
<pre>sn -e C:xxxbinStarCommunity.Core.dll C:tempNetstar.snk</pre>
<p>Since we do not have the private key we must compile with delayed signing. Change the exported <em>AssemblyInfo.cs</em>:</p>
<pre class="csharpcode">[assembly: System.Reflection.AssemblyDelaySign(<span class="kwrd">true</span>)]
[assembly: System.Reflection.AssemblyKeyFile(<span class="str">@&quot;Netstar.snk&quot;</span>)]</pre>
<p>Build project and replace the assembly in the web applications bin-folder.</p>
<h3>3. Get the assembly to load without signing </h3>
<p>Disable Strong Name verification so the dot net framework accepts the patched assembly without signing. Use the Strong Name tool and tell it to skip verification on all assemblies with the public key you exported above. </p>
<pre>sn -Vr *,0bd7a6276e8c109e</pre>
<p>NOTE: The hex code above is from the public-key used by NetStar but you must change it to match the public key in your assembly. The change is global on the machine.</p>
</p>
<h3>4. Restart and test</h3>
<p>Policy changes requires a restarts so do a <em>IISReset</em> to get the patched assembly to load.</p>
<p>Happy coding!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.fredrikhaglund.se/blog/2009/02/06/how-to-patchfixhack-someone-elses-assembly/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>

