<?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>David&#039;s Blog &#187; sn</title>
	<atom:link href="http://www.davidmoore.info/tag/sn/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.davidmoore.info</link>
	<description>Computer says no</description>
	<lastBuildDate>Thu, 26 Jan 2012 21:49:25 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Could not load file or assembly ‘x’ or one of its dependencies. Strong name validation failed.</title>
		<link>http://www.davidmoore.info/2009/05/26/could-not-load-file-or-assembly-x-or-one-of-its-dependencies-strong-name-validation-failed/</link>
		<comments>http://www.davidmoore.info/2009/05/26/could-not-load-file-or-assembly-x-or-one-of-its-dependencies-strong-name-validation-failed/#comments</comments>
		<pubDate>Tue, 26 May 2009 03:54:34 +0000</pubDate>
		<dc:creator>David</dc:creator>
				<category><![CDATA[.net]]></category>
		<category><![CDATA[How To]]></category>
		<category><![CDATA[Software Development]]></category>
		<category><![CDATA[assembly]]></category>
		<category><![CDATA[c#]]></category>
		<category><![CDATA[exception]]></category>
		<category><![CDATA[failed]]></category>
		<category><![CDATA[sn]]></category>
		<category><![CDATA[sn.exe]]></category>
		<category><![CDATA[strong name]]></category>
		<category><![CDATA[validation]]></category>

		<guid isPermaLink="false">http://www.davidmoore.info/?p=153</guid>
		<description><![CDATA[<p>In some of the work I&#8217;m doing right now, I&#8217;m manipulating an assembly after compile time &#8211; having it disassembled into IL, tweaked, then re-compiled back into an assembly.</p>
<p>The assembly is signed and what is being done to the assembly is breaking the strong name. This is quite comforting to know; the strong name wouldn&#8217;t be <span style="color:#777"> . . . &#8594; Read More: <a href="http://www.davidmoore.info/2009/05/26/could-not-load-file-or-assembly-x-or-one-of-its-dependencies-strong-name-validation-failed/">Could not load file or assembly ‘x’ or one of its dependencies. Strong name validation failed.</a></span>]]></description>
			<content:encoded><![CDATA[<p>In some of the work I&#8217;m doing right now, I&#8217;m manipulating an assembly after compile time &#8211; having it disassembled into IL, tweaked, then re-compiled back into an assembly.</p>
<p>The assembly is signed and what is being done to the assembly is breaking the strong name. This is quite comforting to know; the strong name wouldn&#8217;t be so strong if it was that easy to hack an assembly with a strong name.</p>
<p>When trying to load the hacked assembly, I am getting an exception (FileLoadException in this case but I&#8217;m guessing this may differ depending on your assembly load method) with the message &#8220;Could not load file or assembly &#8216;MyAssemblyName&#8217; or one of its dependencies. Strong name validation failed.&#8221;.</p>
<p>The first interesting thing here is that the assembly named in the error message isn&#8217;t the hacked assembly; the hacked assembly is one of MyAssemblyName&#8217;s dependencies and is what&#8217;s triggering the error.</p>
<p><em>Make sure that you check the dependencies of the assembly named in the exception message when troubleshooting. The problem may be with one of the dependencies.</em></p>
<p>In my case the exception isn&#8217;t a surprise because of what&#8217;s being done to the assembly. But until I resolve that, how can I get around this for now?</p>
<p>You can exclude an assembly from strong name validation for development purposes using the <a title="Strong Name Tool" href="http://msdn.microsoft.com/en-us/library/k5b5tt23(VS.71).aspx" onclick="javascript:pageTracker._trackPageview('/outbound/article/msdn.microsoft.com');">Microsoft (R) .NET Framework Strong Name Utility</a> tool aka sn.exe:</p>
<p><code>"%ProgramFiles%\Microsoft SDKs\Windows\v6.0A\bin\sn.exe" -Vr "C:\Path\To\Assembly.dll"</code></p>
<p>Make sure you change the sn.exe path depending on which version of the .NET Framework SDK you have installed. If you&#8217;re having trouble, get into the  &#8221;%ProgramFiles%\Microsoft SDKs\Windows&#8221; dir and search for sn.exe, and use the newest one you can find.</p>
<p>You might find it handy to add this as a Post-build event command-line for your project from within Visual Studio in Project Properties &gt; Build Events:</p>
<p><code>"%ProgramFiles%\Microsoft SDKs\Windows\v6.0A\bin\sn.exe" -Vr "$(TargetPath)"</code></p>
<p>So how do you switch the strong name validation back on for your assembly?</p>
<p>Use the -Vu switch:</p>
<p><code>"%ProgramFiles%\Microsoft SDKs\Windows\v6.0A\bin\sn.exe" -Vu "C:\Path\To\Assembly.dll"</code></p>
]]></content:encoded>
			<wfw:commentRss>http://www.davidmoore.info/2009/05/26/could-not-load-file-or-assembly-x-or-one-of-its-dependencies-strong-name-validation-failed/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

