# OpcClient.AddReferences Method

> Reference: Adds one or more references to existing nodes in the address space hierarchy using the commands specified.

<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">2 overloads · since v2.7</span>

| Overload | Description |
|---|---|
| [AddReferences(IEnumerable&lt;OpcAddReference&gt;)](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcclient/addreferences#addreferences-system-collections-generic-ienumerable-of-opc-uafx-opcaddreference)<span class="api-meta">since v2.7</span> | Adds one or more references to existing nodes in the address space hierarchy using the `commands` specified. |
| [AddReferences(params OpcAddReference\[\])](#addreferences-opc-uafx-opcaddreference-array)<span class="api-meta">since v2.7</span> | Adds one or more references to existing nodes in the address space hierarchy using the `commands` specified. |

**Exceptions (all overloads)**

| Exception | Condition |
|---|---|
| [ArgumentNullException](https://learn.microsoft.com/dotnet/api/system.argumentnullexception) | The `commands` sequence or one of its items is a null reference (Nothing in Visual Basic). |
| [InvalidOperationException](https://learn.microsoft.com/dotnet/api/system.invalidoperationexception) | The add reference service is currently not supported, especially using the `commands` specified. |
| [ObjectDisposedException](https://learn.microsoft.com/dotnet/api/system.objectdisposedexception) | The object has been disposed of. |
| [OpcException](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcexception/) | The service execution failed upon different circumstances; for more details see exception details. The following issues can lead to that exception: [BadNothingToDo](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstatuscode/#badnothingtodo) and [BadTooManyOperations](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstatuscode/#badtoomanyoperations). |

## AddReferences(IEnumerable&lt;OpcAddReference&gt;)

<span class="api-meta">since v2.7</span>

Adds one or more references to existing nodes in the address space hierarchy using the `commands` specified.

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

```csharp
public OpcStatusCollection AddReferences(IEnumerable<OpcAddReference> commands)
```

</div>

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

```vbnet
Public Function AddReferences(
    commands As IEnumerable(Of OpcAddReference)) As OpcStatusCollection
```

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `commands` | [IEnumerable](https://learn.microsoft.com/dotnet/api/system.collections.generic.ienumerable-1)&lt;[OpcAddReference](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcaddreference/)&gt; | A sequence of [OpcAddReference](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcaddreference/) instances to process. |

**Returns**

[OpcStatusCollection](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstatuscollection/)

An instance of the [OpcStatusCollection](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstatuscollection/) class which contains the information about the outcome of each processed command.

**Remarks**

Known results for the `commands` specified are:

| Status | Description |
|---|---|
| [BadSourceNodeIdInvalid](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstatuscode/#badsourcenodeidinvalid) | For more details see [BadSourceNodeIdInvalid](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstatuscode/#badsourcenodeidinvalid). |
| [BadReferenceTypeIdInvalid](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstatuscode/#badreferencetypeidinvalid) | For more details see [BadReferenceTypeIdInvalid](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstatuscode/#badreferencetypeidinvalid). |
| [BadServerUriInvalid](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstatuscode/#badserveruriinvalid) | For more details see [BadServerUriInvalid](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstatuscode/#badserveruriinvalid). |
| [BadTargetNodeIdInvalid](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstatuscode/#badtargetnodeidinvalid) | For more details see [BadTargetNodeIdInvalid](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstatuscode/#badtargetnodeidinvalid). |
| [BadNodeClassInvalid](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstatuscode/#badnodeclassinvalid) | For more details see [BadNodeClassInvalid](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstatuscode/#badnodeclassinvalid). |
| [BadReferenceNotAllowed](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstatuscode/#badreferencenotallowed) | The reference could not be created because it violates constraints imposed by the data model on this server. |
| [BadReferenceLocalOnly](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstatuscode/#badreferencelocalonly) | The reference type is not valid for a reference to a remote server. |
| [BadUserAccessDenied](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstatuscode/#baduseraccessdenied) | For more details see [BadUserAccessDenied](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstatuscode/#baduseraccessdenied). |
| [BadDuplicateReferenceNotAllowed](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstatuscode/#badduplicatereferencenotallowed) | The reference type between the nodes is already defined. |
| [BadInvalidSelfReference](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstatuscode/#badinvalidselfreference) | The server does not allow this type of self reference on this node. |

## AddReferences(params OpcAddReference\[\])

<span class="api-meta">since v2.7</span>

Adds one or more references to existing nodes in the address space hierarchy using the `commands` specified.

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

```csharp
public OpcStatusCollection AddReferences(params OpcAddReference[] commands)
```

</div>

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

```vbnet
Public Function AddReferences(
    ParamArray commands As OpcAddReference()) As OpcStatusCollection
```

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `commands` | params [OpcAddReference](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcaddreference/)[] | An array of [OpcAddReference](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcaddreference/) instances to process. |

**Returns**

[OpcStatusCollection](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstatuscollection/)

An instance of the [OpcStatusCollection](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstatuscollection/) class which contains the information about the outcome of each processed command.

**Remarks**

Known results for the `commands` specified are:

| Status | Description |
|---|---|
| [BadSourceNodeIdInvalid](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstatuscode/#badsourcenodeidinvalid) | For more details see [BadSourceNodeIdInvalid](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstatuscode/#badsourcenodeidinvalid). |
| [BadReferenceTypeIdInvalid](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstatuscode/#badreferencetypeidinvalid) | For more details see [BadReferenceTypeIdInvalid](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstatuscode/#badreferencetypeidinvalid). |
| [BadServerUriInvalid](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstatuscode/#badserveruriinvalid) | For more details see [BadServerUriInvalid](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstatuscode/#badserveruriinvalid). |
| [BadTargetNodeIdInvalid](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstatuscode/#badtargetnodeidinvalid) | For more details see [BadTargetNodeIdInvalid](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstatuscode/#badtargetnodeidinvalid). |
| [BadNodeClassInvalid](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstatuscode/#badnodeclassinvalid) | For more details see [BadNodeClassInvalid](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstatuscode/#badnodeclassinvalid). |
| [BadReferenceNotAllowed](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstatuscode/#badreferencenotallowed) | The reference could not be created because it violates constraints imposed by the data model on this server. |
| [BadReferenceLocalOnly](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstatuscode/#badreferencelocalonly) | The reference type is not valid for a reference to a remote server. |
| [BadUserAccessDenied](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstatuscode/#baduseraccessdenied) | For more details see [BadUserAccessDenied](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstatuscode/#baduseraccessdenied). |
| [BadDuplicateReferenceNotAllowed](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstatuscode/#badduplicatereferencenotallowed) | The reference type between the nodes is already defined. |
| [BadInvalidSelfReference](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstatuscode/#badinvalidselfreference) | The server does not allow this type of self reference on this node. |
