Alex Hoffman

Perspective on development, management and technology

Syndication

News

    Subscribe

    IASA Member

Upgrading 1.x Projects and Friend Assemblies

I'm finding that one new change required on upgrading a project from .NET 1.x  to 2.0 occurs when wanting to make an assembly's internals accessible to another assembly i.e. creating a friend assembly.

In .Net 1.x, one might have default project assembly attributes as follows:-

  1 [assembly: AssemblyDelaySign(false)]
  2 [assembly: AssemblyKeyFile("")]

However, if you add the InternalsVisibleAttributeTo attribute ...

  1 [assembly: InternalsVisibleTo("AxScriptTest")]

... you'll get a compilation error:-

Friend assembly reference 'AxScriptTest' is invalid.
Strong-name signed assemblies must specify a
public key in their InternalsVisibleTo

It seems that the existence of these attributes is enough to make VS2005 think that the assembly is strongly named.  To solve this, simply remove the AssemblyDelaySign and AssemblyKeyFile attributes, or do something like the following:-

  1 #if !DEBUG
  2 	[assembly: AssemblyKeyFile(@"D:\Alintex\Alintex.snk")]
  3 #else
  4 	[assembly: InternalsVisibleTo("AxScriptTest")]
  5 #endif

Published Friday, January 27, 2006 12:48 PM by Alex Hoffman

Filed under:

Comments

# Jason Haley - Interesting Finds@ Friday, January 27, 2006 10:22 PM

Jason Haley - Interesting Finds

TrackBack