<?xml version="1.0" encoding="utf-8"?><!-- generator="wordpress/1.5.1.3" -->
<rss version="2.0" 
	xmlns:content="http://purl.org/rss/1.0/modules/content/">
<channel>
	<title>Comments on: InternalsVisibleTo and strong names</title>
	<link>http://www.sturmnet.org/blog/archives/2005/05/10/internalsvisibleto-sn/</link>
	<description>General musings and programming stuff</description>
	<pubDate>Sat, 22 Nov 2008 12:18:36 +0000</pubDate>
	<generator>http://wordpress.org/?v=1.5.1.3</generator>

	<item>
		<title>by: Brian Johnston</title>
		<link>http://www.sturmnet.org/blog/archives/2005/05/10/internalsvisibleto-sn/#comment-228306</link>
		<pubDate>Fri, 31 Oct 2008 02:38:47 +0000</pubDate>
		<guid>http://www.sturmnet.org/blog/archives/2005/05/10/internalsvisibleto-sn/#comment-228306</guid>
					<description>I can confirm response #14 - in VS2008, had to use PublicKey and full hex public key extracted as shown above.  What a PIA.   Visual Studio team shouldn't make it so hard to do basic security - no wonder so many people don't sign their files when you have to go through all this!</description>
		<content:encoded><![CDATA[	<p>I can confirm response #14 - in VS2008, had to use PublicKey and full hex public key extracted as shown above.  What a PIA.   Visual Studio team shouldn&#8217;t make it so hard to do basic security - no wonder so many people don&#8217;t sign their files when you have to go through all this!
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Pspallone</title>
		<link>http://www.sturmnet.org/blog/archives/2005/05/10/internalsvisibleto-sn/#comment-148709</link>
		<pubDate>Tue, 08 Apr 2008 23:12:36 +0000</pubDate>
		<guid>http://www.sturmnet.org/blog/archives/2005/05/10/internalsvisibleto-sn/#comment-148709</guid>
					<description>I could not get mine to compile and see the internals until I found another post which said to use PublicKey (instead of PublicKeyToken) and use the actual hex public key (extracted from my unitTest binary using sn -Tp myunitTest.dll</description>
		<content:encoded><![CDATA[	<p>I could not get mine to compile and see the internals until I found another post which said to use PublicKey (instead of PublicKeyToken) and use the actual hex public key (extracted from my unitTest binary using sn -Tp myunitTest.dll
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Gareth</title>
		<link>http://www.sturmnet.org/blog/archives/2005/05/10/internalsvisibleto-sn/#comment-145327</link>
		<pubDate>Tue, 25 Mar 2008 15:34:36 +0000</pubDate>
		<guid>http://www.sturmnet.org/blog/archives/2005/05/10/internalsvisibleto-sn/#comment-145327</guid>
					<description>Firstly thanks for the article, im new to c# and .net (came from php5), and this has helped me get InternalsVisibleTo working.  
I do have one slight 'odity' in VS2008 however.  I have a solution with 2 projects, one is the library code the other a unit test project for the library.  When I build the library code all works fine but I don't get the internal class appearing in the intellisense when using the unit test code.  It all compiles fine however - anybody else experiencing this?</description>
		<content:encoded><![CDATA[	<p>Firstly thanks for the article, im new to c# and .net (came from php5), and this has helped me get InternalsVisibleTo working.<br />
I do have one slight &#8216;odity&#8217; in VS2008 however.  I have a solution with 2 projects, one is the library code the other a unit test project for the library.  When I build the library code all works fine but I don&#8217;t get the internal class appearing in the intellisense when using the unit test code.  It all compiles fine however - anybody else experiencing this?
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Michael</title>
		<link>http://www.sturmnet.org/blog/archives/2005/05/10/internalsvisibleto-sn/#comment-143182</link>
		<pubDate>Tue, 18 Mar 2008 21:10:07 +0000</pubDate>
		<guid>http://www.sturmnet.org/blog/archives/2005/05/10/internalsvisibleto-sn/#comment-143182</guid>
					<description>&amp;#34;The latest version of the Enterprise Library comes strong named.&amp;#34;. I found the lastest version of the Library doesn't includes strong name
 
&amp;#60;a href=&amp;#34;http://www.microsoft.com/downloads/details.aspx?FamilyId=4C557C63-708F-4280-8F0C-637481C31718&amp;#38;displaylang=en&amp;#34;&amp;#62; latest library&amp;#60;/a&amp;#62;

Is this link correct? 

Thank you!</description>
		<content:encoded><![CDATA[	<p>&quot;The latest version of the Enterprise Library comes strong named.&quot;. I found the lastest version of the Library doesn&#8217;t includes strong name</p>
	<p>&lt;a href=&quot;http://www.microsoft.com/downloads/details.aspx?FamilyId=4C557C63-708F-4280-8F0C-637481C31718&amp;displaylang=en&quot;&gt; latest library&lt;/a&gt;</p>
	<p>Is this link correct? </p>
	<p>Thank you!
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Jeremy</title>
		<link>http://www.sturmnet.org/blog/archives/2005/05/10/internalsvisibleto-sn/#comment-139607</link>
		<pubDate>Tue, 04 Mar 2008 23:29:25 +0000</pubDate>
		<guid>http://www.sturmnet.org/blog/archives/2005/05/10/internalsvisibleto-sn/#comment-139607</guid>
					<description>Thanks for the info. Very helpful.

new - 
The latest version of the Enterprise Library comes strong named. Otherwise, you just have to download the source, go into each project and sign each. Its a PITA, but once you're done, you have a nice set of signed Enterprise Library dlls.</description>
		<content:encoded><![CDATA[	<p>Thanks for the info. Very helpful.</p>
	<p>new -<br />
The latest version of the Enterprise Library comes strong named. Otherwise, you just have to download the source, go into each project and sign each. Its a PITA, but once you&#8217;re done, you have a nice set of signed Enterprise Library dlls.
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: nev</title>
		<link>http://www.sturmnet.org/blog/archives/2005/05/10/internalsvisibleto-sn/#comment-139475</link>
		<pubDate>Tue, 04 Mar 2008 10:25:49 +0000</pubDate>
		<guid>http://www.sturmnet.org/blog/archives/2005/05/10/internalsvisibleto-sn/#comment-139475</guid>
					<description>Im working with the Data Block of the Enterprise Library.
Both PublicKey and PublicKeyToken didnt work for me. There seems to be an endless nesting of referenced assemblies that I have to add this attribute to. What is the workaround if any?</description>
		<content:encoded><![CDATA[	<p>Im working with the Data Block of the Enterprise Library.<br />
Both PublicKey and PublicKeyToken didnt work for me. There seems to be an endless nesting of referenced assemblies that I have to add this attribute to. What is the workaround if any?
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Michael Flanakin</title>
		<link>http://www.sturmnet.org/blog/archives/2005/05/10/internalsvisibleto-sn/#comment-127021</link>
		<pubDate>Thu, 17 Jan 2008 14:07:47 +0000</pubDate>
		<guid>http://www.sturmnet.org/blog/archives/2005/05/10/internalsvisibleto-sn/#comment-127021</guid>
					<description>Just wanted to confirm Andrew's comment -- VS 2008 requires PublicKey; PublicKeyToken does not work.</description>
		<content:encoded><![CDATA[	<p>Just wanted to confirm Andrew&#8217;s comment &#8212; VS 2008 requires PublicKey; PublicKeyToken does not work.
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Andrew</title>
		<link>http://www.sturmnet.org/blog/archives/2005/05/10/internalsvisibleto-sn/#comment-125599</link>
		<pubDate>Tue, 08 Jan 2008 03:52:03 +0000</pubDate>
		<guid>http://www.sturmnet.org/blog/archives/2005/05/10/internalsvisibleto-sn/#comment-125599</guid>
					<description>Thank you very much! 

Specifying [InternalsVisibleTo(&amp;#34;MyDll, PublicKey=...&amp;#34;)] worked beautifully. 

Visual Studio 2008 just simply refused to accepted [InternalsVisibleTo(&amp;#34;MyDll, PublicKeyToken=...&amp;#34;)]

Thanks again!</description>
		<content:encoded><![CDATA[	<p>Thank you very much! </p>
	<p>Specifying [InternalsVisibleTo(&quot;MyDll, PublicKey=&#8230;&quot;)] worked beautifully. </p>
	<p>Visual Studio 2008 just simply refused to accepted [InternalsVisibleTo(&quot;MyDll, PublicKeyToken=&#8230;&quot;)]</p>
	<p>Thanks again!
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Justin Scott</title>
		<link>http://www.sturmnet.org/blog/archives/2005/05/10/internalsvisibleto-sn/#comment-119201</link>
		<pubDate>Mon, 03 Dec 2007 19:08:09 +0000</pubDate>
		<guid>http://www.sturmnet.org/blog/archives/2005/05/10/internalsvisibleto-sn/#comment-119201</guid>
					<description>Scratch that; I am not able to get PublicKeyToken to work as desired in Orcas.  

However, PublicKey still works A-OK.

Use 
sn -Tp assembly.dll

which will return:
PublicKey=00240000048...9
PublicKeyToken=123456789abcdef0

Then in code:
[assembly: InternalsVisibleTo(&amp;#34;UnitTests, PublicKey=00240000048...9&amp;#34;)]</description>
		<content:encoded><![CDATA[	<p>Scratch that; I am not able to get PublicKeyToken to work as desired in Orcas.  </p>
	<p>However, PublicKey still works A-OK.</p>
	<p>Use<br />
sn -Tp assembly.dll</p>
	<p>which will return:<br />
PublicKey=00240000048&#8230;9<br />
PublicKeyToken=123456789abcdef0</p>
	<p>Then in code:<br />
[assembly: InternalsVisibleTo(&quot;UnitTests, PublicKey=00240000048&#8230;9&quot;)]
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Justin Scott</title>
		<link>http://www.sturmnet.org/blog/archives/2005/05/10/internalsvisibleto-sn/#comment-119194</link>
		<pubDate>Mon, 03 Dec 2007 18:44:00 +0000</pubDate>
		<guid>http://www.sturmnet.org/blog/archives/2005/05/10/internalsvisibleto-sn/#comment-119194</guid>
					<description>Command is slightly wrong:

Try this:
[assembly: InternalsVisibleTo(&amp;#34;UnitTests, PublicKeyToken=&amp;#60;123456789abcdef0&amp;#62;&amp;#34;)]</description>
		<content:encoded><![CDATA[	<p>Command is slightly wrong:</p>
	<p>Try this:<br />
[assembly: InternalsVisibleTo(&quot;UnitTests, PublicKeyToken=&lt;123456789abcdef0&gt;&quot;)]
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Oliver Sturm</title>
		<link>http://www.sturmnet.org/blog/archives/2005/05/10/internalsvisibleto-sn/#comment-12688</link>
		<pubDate>Mon, 13 Mar 2006 15:44:57 +0000</pubDate>
		<guid>http://www.sturmnet.org/blog/archives/2005/05/10/internalsvisibleto-sn/#comment-12688</guid>
					<description>Hey Neil - 
Certainly an interesting hint, but do you find this more useful? I tried it with my own key and while the token has 16 chars (8 bytes), the complete key string is more than 320 chars long. If I have the choice, I'll still go with the token :-)</description>
		<content:encoded><![CDATA[	<p>Hey Neil -<br />
Certainly an interesting hint, but do you find this more useful? I tried it with my own key and while the token has 16 chars (8 bytes), the complete key string is more than 320 chars long. If I have the choice, I&#8217;ll still go with the token <img src='http://www.sturmnet.org/blog/wp-images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Neil Mosafi</title>
		<link>http://www.sturmnet.org/blog/archives/2005/05/10/internalsvisibleto-sn/#comment-12687</link>
		<pubDate>Mon, 13 Mar 2006 15:38:31 +0000</pubDate>
		<guid>http://www.sturmnet.org/blog/archives/2005/05/10/internalsvisibleto-sn/#comment-12687</guid>
					<description>Hi

The InternalsVisibleTo attribute now uses the public key of the assembly, rather than the public key token.  This can be extracted by running:

sn -tp mykey.pub

and using PublicKey= rather than PublicKeyToken=</description>
		<content:encoded><![CDATA[	<p>Hi</p>
	<p>The InternalsVisibleTo attribute now uses the public key of the assembly, rather than the public key token.  This can be extracted by running:</p>
	<p>sn -tp mykey.pub</p>
	<p>and using PublicKey= rather than PublicKeyToken=
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Andrew Davey</title>
		<link>http://www.sturmnet.org/blog/archives/2005/05/10/internalsvisibleto-sn/#comment-5638</link>
		<pubDate>Wed, 23 Nov 2005 04:36:33 +0000</pubDate>
		<guid>http://www.sturmnet.org/blog/archives/2005/05/10/internalsvisibleto-sn/#comment-5638</guid>
					<description>Hi, I have come across your same error but with the difference being none of my assemblies were strongly signed.

At first I thought that the documentation included was incorrect and that the final release would only allow you to use the InternalsVisibleTo attribute on strongly signed assemblies. I was in the middle of writing something to MS when I tried to compile their example and was surprised when it worked.

So after much headscractching I discovered that if I removed the following three attributes from my ported AssemblyInfo.cs file:

&lt;code&gt;
[assembly: AssemblyDelaySign(false)]
[assembly: AssemblyKeyFile(&quot;&quot;)]
[assembly: AssemblyKeyName(&quot;&quot;)]
&lt;/code&gt;

Then my error went away. It seems that if the compiler detects the presense of these attributes, for the purposes of the InternalsVisibleTo, it seems to think that the assembly is strongly signed.</description>
		<content:encoded><![CDATA[	<p>Hi, I have come across your same error but with the difference being none of my assemblies were strongly signed.</p>
	<p>At first I thought that the documentation included was incorrect and that the final release would only allow you to use the InternalsVisibleTo attribute on strongly signed assemblies. I was in the middle of writing something to MS when I tried to compile their example and was surprised when it worked.</p>
	<p>So after much headscractching I discovered that if I removed the following three attributes from my ported AssemblyInfo.cs file:</p>
	<p><code><br />
[assembly: AssemblyDelaySign(false)]<br />
[assembly: AssemblyKeyFile("")]<br />
[assembly: AssemblyKeyName("")]<br />
</code></p>
	<p>Then my error went away. It seems that if the compiler detects the presense of these attributes, for the purposes of the InternalsVisibleTo, it seems to think that the assembly is strongly signed.
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Oliver Sturm</title>
		<link>http://www.sturmnet.org/blog/archives/2005/05/10/internalsvisibleto-sn/#comment-3703</link>
		<pubDate>Thu, 20 Oct 2005 08:49:16 +0000</pubDate>
		<guid>http://www.sturmnet.org/blog/archives/2005/05/10/internalsvisibleto-sn/#comment-3703</guid>
					<description>It does sound correct. What is the error you're getting? The same message I showed above? 

I just double-checked and I find there has to be something funny going on on your end. The thing is this: the compiler checks only for the valid syntax of the string passed to the InternalsVisibleTo attribute. For example, you can even use the string shown above, with the nonsense public key token in it, to make the compiler happy. So if you're still getting errors, there must be another reason... are you sure you're not seeing old messages? VS is sometimes great at this... To be sure, the best way is to switch to the Output tab after a compiler run (not the Error list tab!) and check the output carefully - maybe there's some other problem and VS is showing you the old error.</description>
		<content:encoded><![CDATA[	<p>It does sound correct. What is the error you&#8217;re getting? The same message I showed above? </p>
	<p>I just double-checked and I find there has to be something funny going on on your end. The thing is this: the compiler checks only for the valid syntax of the string passed to the InternalsVisibleTo attribute. For example, you can even use the string shown above, with the nonsense public key token in it, to make the compiler happy. So if you&#8217;re still getting errors, there must be another reason&#8230; are you sure you&#8217;re not seeing old messages? VS is sometimes great at this&#8230; To be sure, the best way is to switch to the Output tab after a compiler run (not the Error list tab!) and check the output carefully - maybe there&#8217;s some other problem and VS is showing you the old error.
</p>
]]></content:encoded>
				</item>
	<item>
		<title>by: Brad Thompson</title>
		<link>http://www.sturmnet.org/blog/archives/2005/05/10/internalsvisibleto-sn/#comment-3687</link>
		<pubDate>Wed, 19 Oct 2005 23:31:42 +0000</pubDate>
		<guid>http://www.sturmnet.org/blog/archives/2005/05/10/internalsvisibleto-sn/#comment-3687</guid>
					<description>Unfortunately, this doesn't work for me. My method was to edit the unittest code to comment out all references to the main dll. Then compile it with a strong key that I created with sn.exe. I then used sn.exe to get the public key. I included this in the main dll assembly exactly as above, but when I compile I still get the same error. I even GACed the unittest.dll file. Is there anything wrong with my approach?</description>
		<content:encoded><![CDATA[	<p>Unfortunately, this doesn&#8217;t work for me. My method was to edit the unittest code to comment out all references to the main dll. Then compile it with a strong key that I created with sn.exe. I then used sn.exe to get the public key. I included this in the main dll assembly exactly as above, but when I compile I still get the same error. I even GACed the unittest.dll file. Is there anything wrong with my approach?
</p>
]]></content:encoded>
				</item>
</channel>
</rss>
