# OpcClient.DeleteNode Method

> Reference: Deletes a node from the address space hierarchy using the command 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">3 overloads</span>

| Overload | Description |
|---|---|
| [DeleteNode(OpcDeleteNode)](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcclient/deletenode#deletenode-opc-uafx-opcdeletenode)<span class="api-meta">since v2.7</span> | Deletes a node from the address space hierarchy using the `command` specified. |
| [DeleteNode(OpcNodeId)](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcclient/deletenode#deletenode-opc-uafx-opcnodeid) | Deletes a node from the address space hierarchy using the identifier of the node which shall be deleted including the references where the node acts as the source and as the target of the reference. |
| [DeleteNode(OpcNodeId, bool)](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcclient/deletenode#deletenode-opc-uafx-opcnodeid-system-boolean) | Deletes a node from the address space hierarchy using the identifier of the node which shall be deleted including the references where the node acts as the source and optionally (see `includeTargetReferences`) as the target of the reference. |

**Exceptions (all overloads)**

| Exception | Condition |
|---|---|
| [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). |

## DeleteNode(OpcDeleteNode)

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

Deletes a node from the address space hierarchy using the `command` specified.

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

```csharp
public OpcStatus DeleteNode(OpcDeleteNode command)
```

</div>

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

```vbnet
Public Function DeleteNode(command As OpcDeleteNode) As OpcStatus
```

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `command` | [OpcDeleteNode](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcdeletenode/) | The [OpcDeleteNode](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcdeletenode/) instance to process. |

**Returns**

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

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

**Exceptions**

| Exception | Condition |
|---|---|
| [ArgumentNullException](https://learn.microsoft.com/dotnet/api/system.argumentnullexception) | The `command` is a null reference (Nothing in Visual Basic). |
| [InvalidOperationException](https://learn.microsoft.com/dotnet/api/system.invalidoperationexception) | The add node service is currently not supported, especially using the `command` specified. |

**Remarks**

Known results for the `command` specified are:

| Status | Description |
|---|---|
| [BadNodeIdInvalid](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstatuscode/#badnodeidinvalid) | For more details see [BadNodeIdInvalid](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstatuscode/#badnodeidinvalid). |
| [BadNodeIdUnknown](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstatuscode/#badnodeidunknown) | For more details see [BadNodeIdUnknown](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstatuscode/#badnodeidunknown). |
| [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). |
| [BadNoDeleteRights](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstatuscode/#badnodeleterights) | For more details see [BadNoDeleteRights](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstatuscode/#badnodeleterights). |
| [UncertainReferenceNotDeleted](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstatuscode/#uncertainreferencenotdeleted) | The server was not able to delete all target references. |

## DeleteNode(OpcNodeId)

Deletes a node from the address space hierarchy using the identifier of the node which shall be deleted including the references where the node acts as the source and as the target of the reference.

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

```csharp
public OpcStatus DeleteNode(OpcNodeId nodeId)
```

</div>

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

```vbnet
Public Function DeleteNode(nodeId As OpcNodeId) As OpcStatus
```

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `nodeId` | [OpcNodeId](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodeid/) | The [OpcNodeId](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodeid/) through that the node to delete can be identified and accessed. |

**Returns**

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

**Exceptions**

| Exception | Condition |
|---|---|
| [ArgumentException](https://learn.microsoft.com/dotnet/api/system.argumentexception) | The `nodeId` is equals [Null](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodeid/members#null). |
| [ArgumentNullException](https://learn.microsoft.com/dotnet/api/system.argumentnullexception) | The `nodeId` is a null reference (Nothing in Visual Basic). |
| [InvalidOperationException](https://learn.microsoft.com/dotnet/api/system.invalidoperationexception) | The delete node service is currently not supported, especially using the parameters specified. |

**Remarks**

Known results for the service invocation are:

| Status | Description |
|---|---|
| [BadNodeIdInvalid](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstatuscode/#badnodeidinvalid) | For more details see [BadNodeIdInvalid](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstatuscode/#badnodeidinvalid). |
| [BadNodeIdUnknown](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstatuscode/#badnodeidunknown) | For more details see [BadNodeIdUnknown](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstatuscode/#badnodeidunknown). |
| [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). |
| [BadNoDeleteRights](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstatuscode/#badnodeleterights) | For more details see [BadNoDeleteRights](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstatuscode/#badnodeleterights). |
| [UncertainReferenceNotDeleted](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstatuscode/#uncertainreferencenotdeleted) | The server was not able to delete all target references. |

## DeleteNode(OpcNodeId, bool)

Deletes a node from the address space hierarchy using the identifier of the node which shall be deleted including the references where the node acts as the source and optionally (see `includeTargetReferences`) as the target of the reference.

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

```csharp
public OpcStatus DeleteNode(OpcNodeId nodeId, bool includeTargetReferences)
```

</div>

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

```vbnet
Public Function DeleteNode(
    nodeId As OpcNodeId,
    includeTargetReferences As Boolean) As OpcStatus
```

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `nodeId` | [OpcNodeId](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodeid/) | The [OpcNodeId](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodeid/) through that the node to delete can be identified and accessed. |
| `includeTargetReferences` | [Boolean](https://learn.microsoft.com/dotnet/api/system.boolean) | A value indicating whether all references there the node being deleted acts as the target shall be deleted as well. The value true if all references using the node to delete as the target of the reference shall be deleted as well; otherwise the value false which indicates that only references there the node to delete acts as the source of the reference. |

**Returns**

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

**Exceptions**

| Exception | Condition |
|---|---|
| [ArgumentException](https://learn.microsoft.com/dotnet/api/system.argumentexception) | The `nodeId` is equals [Null](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodeid/members#null). |
| [ArgumentNullException](https://learn.microsoft.com/dotnet/api/system.argumentnullexception) | The `nodeId` is a null reference (Nothing in Visual Basic). |
| [InvalidOperationException](https://learn.microsoft.com/dotnet/api/system.invalidoperationexception) | The delete node service is currently not supported, especially using the parameters specified. |

**Remarks**

Known results for the service invocation are:

| Status | Description |
|---|---|
| [BadNodeIdInvalid](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstatuscode/#badnodeidinvalid) | For more details see [BadNodeIdInvalid](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstatuscode/#badnodeidinvalid). |
| [BadNodeIdUnknown](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstatuscode/#badnodeidunknown) | For more details see [BadNodeIdUnknown](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstatuscode/#badnodeidunknown). |
| [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). |
| [BadNoDeleteRights](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstatuscode/#badnodeleterights) | For more details see [BadNoDeleteRights](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstatuscode/#badnodeleterights). |
| [UncertainReferenceNotDeleted](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstatuscode/#uncertainreferencenotdeleted) | The server was not able to delete all target references. |
