InternalsVisibleToAttribute Class

[This documentation is for preview only, and is subject to change in later releases. Blank topics are included as placeholders.]

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


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

[<AttributeUsageAttribute(AttributeTargets.Assembly, AllowMultiple = true, Inherited = false)>]
type InternalsVisibleToAttribute =  
        inherit Attribute

The InternalsVisibleToAttribute type exposes the following members.

Public methodInternalsVisibleToAttributeInitializes a new instance of the InternalsVisibleToAttribute class with the name of the specified friend assembly.

Public propertyAssemblyNameGets the name of the friend assembly to which all types and type members that are marked with the internal keyword are to be made visible.

Public methodEquals(Object)Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Public methodGetHashCodeServes as a hash function for a particular type. (Inherited from Object.)
Public methodGetTypeGets the Type of the current instance. (Inherited from Object.)
Public methodToStringReturns a string that represents the current object. (Inherited from Object.)

Ordinarily, types and members with internal scope (in C#) and friend scope (in Visual Basic) are visible only in the assembly in which they are defined. The InternalsVisibleToAttribute attribute makes them also visible to the types in a specified assembly, which is known as a friend assembly.

The attribute is applied at the assembly level. This means that it can be included at the beginning of a source code file, or it can be included in the AssemblyInfo file in a Visual Studio project. You can use the attribute to specify a single friend assembly that can access the internal types and members of the current assembly. You can define multiple friend assemblies in two ways. They can appear as individual assembly-level attributes.

They can also appear with separate InternalsVisibleToAttribute tags but a single assembly keyword.

The friend assembly is identified by the InternalsVisibleToAttribute constructor. Both the current assembly and the friend assembly must be unsigned, or both assemblies must be signed with a strong name. If they are signed with a strong name, the argument to the InternalsVisibleToAttribute constructor must include the full public key as well as the name of the assembly. For more information about using InternalsVisibleToAttribute with strong-named assemblies, see the InternalsVisibleToAttribute constructor.

If you use the C# compiler to compile the friend assembly, you must explicitly specify the name of the output file (.exe or .dll) by using the /out compiler option. This is required because the compiler has not yet generated the name for the assembly it is building at the time it is binding to external references. The /out compiler option is optional for the Visual Basic compiler.

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