# OpcClient Constructors

> Reference: Initializes a new instance of the OpcClient class.

<dl class="api-definition">
<dt>Type</dt>
<dd><a href="./">OpcClient</a></dd>
<dt>Namespace</dt>
<dd><a href="../namespaces/opc.uafx.client">Opc.UaFx.Client</a></dd>
<dt>Assembly</dt>
<dd>Opc.UaFx.Advanced.dll</dd>
<dt>Package</dt>
<dd>Opc.UaFx.Advanced v2.59.0</dd>
<dt>Members</dt>
<dd><a href="./members">OpcClient Members</a></dd>
<dt>Also in</dt>
<dd>Opc.UaFx.Client</dd>
</dl>

<span class="api-meta">5 overloads</span>

| Overload | Description |
|---|---|
| [OpcClient()](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcclient/opcclient#opcclient-noparams) | Initializes a new instance of the [OpcClient](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcclient/) class. |
| [OpcClient(string)](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcclient/opcclient#opcclient-system-string) | Initializes a new instance of the [OpcClient](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcclient/) class using the specified `serverAddress`. |
| [OpcClient(Uri)](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcclient/opcclient#opcclient-system-uri) | Initializes a new instance of the [OpcClient](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcclient/) class using the specified `serverAddress`. |
| [OpcClient(string, OpcSecurityPolicy)](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcclient/opcclient#opcclient-system-string-opc-uafx-opcsecuritypolicy) | Initializes a new instance of the [OpcClient](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcclient/) class using the specified `serverAddress` and `endpointPolicy`. |
| [OpcClient(Uri, OpcSecurityPolicy)](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcclient/opcclient#opcclient-system-uri-opc-uafx-opcsecuritypolicy) | Initializes a new instance of the [OpcClient](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcclient/) class using the specified `serverAddress` and `endpointPolicy`. |

## OpcClient()

Initializes a new instance of the [OpcClient](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcclient/) class.

<div class="api-signature" data-lang="csharp">

```csharp
public OpcClient()
```

</div>

<div class="api-signature" data-lang="vbnet">

```vbnet
Public Sub New()
```

</div>

**Exceptions**

| Exception | Condition |
|---|---|
| [LicenseException](https://learn.microsoft.com/dotnet/api/system.componentmodel.licenseexception) | The license is expired. |

## OpcClient(string)

Initializes a new instance of the [OpcClient](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcclient/) class using the specified `serverAddress`.

<div class="api-signature" data-lang="csharp">

```csharp
public OpcClient(string serverAddress)
```

</div>

<div class="api-signature" data-lang="vbnet">

```vbnet
Public Sub New(serverAddress As String)
```

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `serverAddress` | [String](https://learn.microsoft.com/dotnet/api/system.string) | The URI of the OPC UA server to operate on. |

**Exceptions**

| Exception | Condition |
|---|---|
| [ArgumentException](https://learn.microsoft.com/dotnet/api/system.argumentexception) | The `serverAddress` is an empty string. |
| [ArgumentNullException](https://learn.microsoft.com/dotnet/api/system.argumentnullexception) | The `serverAddress` is a null reference (Nothing in Visual Basic). |
| [UriFormatException](https://learn.microsoft.com/dotnet/api/system.uriformatexception) | The `serverAddress` is not a valid URI. |

## OpcClient(Uri)

Initializes a new instance of the [OpcClient](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcclient/) class using the specified `serverAddress`.

<div class="api-signature" data-lang="csharp">

```csharp
public OpcClient(Uri serverAddress)
```

</div>

<div class="api-signature" data-lang="vbnet">

```vbnet
Public Sub New(serverAddress As Uri)
```

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `serverAddress` | [Uri](https://learn.microsoft.com/dotnet/api/system.uri) | The [Uri](https://learn.microsoft.com/dotnet/api/system.uri) of the OPC UA server to operate on. |

**Exceptions**

| Exception | Condition |
|---|---|
| [ArgumentNullException](https://learn.microsoft.com/dotnet/api/system.argumentnullexception) | The `serverAddress` is a null reference (Nothing in Visual Basic). |

## OpcClient(string, OpcSecurityPolicy)

Initializes a new instance of the [OpcClient](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcclient/) class using the specified `serverAddress` and `endpointPolicy`.

<div class="api-signature" data-lang="csharp">

```csharp
public OpcClient(string serverAddress, OpcSecurityPolicy endpointPolicy)
```

</div>

<div class="api-signature" data-lang="vbnet">

```vbnet
Public Sub New(serverAddress As String, endpointPolicy As OpcSecurityPolicy)
```

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `serverAddress` | [String](https://learn.microsoft.com/dotnet/api/system.string) | The URI of the OPC UA server to operate on. |
| `endpointPolicy` | [OpcSecurityPolicy](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcsecuritypolicy/) | The preferred security policy configuration which is to be provided by one of the endpoints defined by the server to operate on. |

**Exceptions**

| Exception | Condition |
|---|---|
| [ArgumentException](https://learn.microsoft.com/dotnet/api/system.argumentexception) | The `serverAddress` is an empty string. |
| [ArgumentNullException](https://learn.microsoft.com/dotnet/api/system.argumentnullexception) | The `serverAddress` or `endpointPolicy` is a null reference (Nothing in Visual Basic). |
| [UriFormatException](https://learn.microsoft.com/dotnet/api/system.uriformatexception) | The `serverAddress` is not a valid URI. |

## OpcClient(Uri, OpcSecurityPolicy)

Initializes a new instance of the [OpcClient](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcclient/) class using the specified `serverAddress` and `endpointPolicy`.

<div class="api-signature" data-lang="csharp">

```csharp
public OpcClient(Uri serverAddress, OpcSecurityPolicy endpointPolicy)
```

</div>

<div class="api-signature" data-lang="vbnet">

```vbnet
Public Sub New(serverAddress As Uri, endpointPolicy As OpcSecurityPolicy)
```

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `serverAddress` | [Uri](https://learn.microsoft.com/dotnet/api/system.uri) | The [Uri](https://learn.microsoft.com/dotnet/api/system.uri) of the OPC UA server to operate on. |
| `endpointPolicy` | [OpcSecurityPolicy](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcsecuritypolicy/) | The preferred security policy configuration which is to be provided by one of the endpoints defined by the server to operate on. |

**Exceptions**

| Exception | Condition |
|---|---|
| [ArgumentNullException](https://learn.microsoft.com/dotnet/api/system.argumentnullexception) | The `serverAddress` or `endpointPolicy` is a null reference (Nothing in Visual Basic). |
