Export (0) Print
Expand All

InternalsVisibleToAttribute Class

Specifies that types that are ordinarily visible only within the current assembly are visible to another assembly.

Namespace: System.Runtime.CompilerServices
Assembly: mscorlib (in mscorlib.dll)

[AttributeUsageAttribute(AttributeTargets::Assembly, AllowMultiple=true, Inherited=false)] 
public ref class InternalsVisibleToAttribute sealed : public Attribute
/** @attribute AttributeUsageAttribute(AttributeTargets.Assembly, AllowMultiple=true, Inherited=false) */ 
public final class InternalsVisibleToAttribute extends Attribute
AttributeUsageAttribute(AttributeTargets.Assembly, AllowMultiple=true, Inherited=false) 
public final class InternalsVisibleToAttribute extends Attribute
Not applicable.

This attribute applies to internal types in C#, friend types in Visual Basic, and all types at namespace or global scope in C++. To apply this attribute to a strong-named friend assembly, you must know the hexadecimal string that represents the public key of the friend assembly. For more information, see How to: Sign an Assembly with a Strong Name.

Do not include values for the CultureInfo, Version, or ProcessorArchitecture fields in the string parameter of the friend assembly declaration. The Visual Basic, C#, and C++ compilers treat this as a compile error. If you use a compiler (such as the MSIL Assembler (Ilasm.exe)) that does not treat it as an error and the assemblies are strong-named, a MethodAccessException is thrown the first time the specified friend assembly accesses the assembly that contains InternalsVisibleToAttribute.

The following example makes types and type members that are marked with the internal keyword in the declaring assembly visible to AssemblyB, to all versions of AssemblyB, and to all variants of AssemblyB that might contain different cultures.

[assembly:InternalsVisibleTo("AssemblyB, PublicKey=32ab4ba45e0a69a1")]

System.Object
   System.Attribute
    System.Runtime.CompilerServices.InternalsVisibleToAttribute

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0

.NET Compact Framework

Supported in: 2.0

XNA Framework

Supported in: 1.0

Community Additions

ADD
Show:
© 2014 Microsoft