Updated: December 2009
Initializes a new instance of the InternalsVisibleToAttribute class with the name of the specified friend assembly.
Assembly: mscorlib (in mscorlib.dll)
The constructor defines a friend assembly, which is an assembly that has access to the internal types and members of the current assembly.
Both the current assembly and the friend assembly must be unsigned, or both must be signed with a strong name. (For more information about strong-named assemblies, see Creating and Using Strong-Named Assemblies.) If both are unsigned, the assemblyName parameter consists of the name of the friend assembly, specified without a directory path or file extension. If both are signed, assemblyName consists of the name of the friend assembly along with its full public key (but not its public key token). The other components of a strong name, such as those that provide culture, version, or processor architecture information, cannot be specified in the assemblyName parameter.
You can use Strong Name Tool (Sn.exe) to retrieve the full public key from a strong-named key (.snk) file. To do this, you perform the following steps:
Extract the public key from the strong-named key file to a separate file:
Sn -p snk_file outfile
Display the full public key to the console:
Sn -tp outfile
Copy and paste the full public key value into your source code.
For more information about how to use the InternalsVisibleToAttribute attribute, see the following topics:
The following example defines a FileUtilities class that includes an internal AppendDirectorySeparator method. The InternalsVisibleToAttribute attribute is applied to the assembly that contains the FileUtilities class. The attribute allows an assembly named Friend1 to access this internal member.
If the following example is compiled into a strong-named assembly named Friend1, it can successfully call the FileUtilities.AppendDirectorySeparator method, even though the method is internal to the Assembly1 assembly.
Windows 7, Windows Vista, Windows XP SP2, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP Starter Edition, Windows Server 2008 R2, Windows Server 2008, Windows Server 2003, Windows Server 2000 SP4, Windows Millennium Edition, Windows 98, Windows CE, Windows Mobile for Smartphone, Windows Mobile for Pocket PC, Xbox 360, Zune
The .NET Framework and .NET Compact Framework do not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.