This documentation is archived and is not being maintained.

CodeConnectAccess Constructor

Initializes a new instance of the CodeConnectAccess class.

Namespace:  System.Security.Policy
Assembly:  mscorlib (in mscorlib.dll)

public CodeConnectAccess(
	string allowScheme,
	int allowPort


Type: System.String
The URI scheme represented by the current instance.
Type: System.Int32
The port represented by the current instance.


allowScheme is null.


allowScheme is an empty string ("").


allowScheme contains characters that are not permitted in schemes.


allowPort is less than 0.


allowPort is greater than 65,535.

The Scheme property is set using the allowScheme parameter. The scheme is converted to lowercase. The value of Scheme controls the scheme that executing code can use to connect to a network resource.

The Port property is set using the allowPort parameter. The value of Port controls the port that executing code can use to connect to a network resource.

The following code example demonstrates creating a CodeConnectAccess object that permits downloaded code to connect back to its origin server using the HTTP protocol and the same port it was downloaded on. For an example that demonstrates using CodeConnectAccess objects to create a code group and adding the code group to a policy level, see the CodeConnectAccess class overview.

    public static CodeConnectAccess CreateHttpAndOriginPortAccess()
    return new CodeConnectAccess(Uri.UriSchemeHttp, CodeConnectAccess.OriginPort);

.NET Framework

Supported in: 4, 3.5, 3.0, 2.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.