# OpcClient.CallMethod Method

> Reference: Calls the method as defined by 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">4 overloads</span>

| Overload | Description |
|---|---|
| [CallMethod(OpcNodeId, OpcNodeId)](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcclient/callmethod#callmethod-opc-uafx-opcnodeid-opc-uafx-opcnodeid) | Calls the method identified by the `methodId` on the object identified by the `objectId` specified without any input arguments. |
| [CallMethod(OpcNodeId, OpcNodeId, IEnumerable&lt;object&gt;)](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcclient/callmethod#callmethod-opc-uafx-opcnodeid-opc-uafx-opcnodeid-system-collections-generic-ienumerable-of-system-object) | Calls the method identified by the `methodId` on the object identified by the `objectId` specified using the `parameters` as the values of its input arguments. |
| [CallMethod(OpcNodeId, OpcNodeId, params object\[\])](#callmethod-opc-uafx-opcnodeid-opc-uafx-opcnodeid-system-object-array) | Calls the method identified by the `methodId` on the object identified by the `objectId` specified using the `parameters` as the values of its input arguments. |
| [CallMethod(OpcCallMethod)](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.client.opcclient/callmethod#callmethod-opc-uafx-opccallmethod)<span class="api-meta">since v2.8</span> | Calls the method as defined by the `command` specified. |

**Exceptions (all overloads)**

| Exception | Condition |
|---|---|
| [OpcException](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcexception/) | The client is not connected to the server, the service execution failed or the server reported a bad status code for the call or for one of its input arguments. |
| [ObjectDisposedException](https://learn.microsoft.com/dotnet/api/system.objectdisposedexception) | The object has been disposed of. |

## CallMethod(OpcNodeId, OpcNodeId)

Calls the method identified by the `methodId` on the object identified by the `objectId` specified without any input arguments.

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

```csharp
public object[] CallMethod(OpcNodeId objectId, OpcNodeId methodId)
```

</div>

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

```vbnet
Public Function CallMethod(
    objectId As OpcNodeId,
    methodId As OpcNodeId) As Object()
```

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `objectId` | [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/) of the object on which the method is to be called. |
| `methodId` | [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/) of the method to call. |

**Returns**

[Object](https://learn.microsoft.com/dotnet/api/system.object)[]

An array of the values of the output arguments returned by the method.

**Exceptions**

| Exception | Condition |
|---|---|
| [ArgumentException](https://learn.microsoft.com/dotnet/api/system.argumentexception) | The `objectId` is a null identifier (see [IsNull](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodeid/members#isnull)). |
| [ArgumentNullException](https://learn.microsoft.com/dotnet/api/system.argumentnullexception) | The `objectId` or `methodId` is a null reference (Nothing in Visual Basic). |

## CallMethod(OpcNodeId, OpcNodeId, IEnumerable&lt;object&gt;)

Calls the method identified by the `methodId` on the object identified by the `objectId` specified using the `parameters` as the values of its input arguments.

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

```csharp
public object[] CallMethod(
    OpcNodeId objectId,
    OpcNodeId methodId,
    IEnumerable<object> parameters)
```

</div>

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

```vbnet
Public Function CallMethod(
    objectId As OpcNodeId,
    methodId As OpcNodeId,
    parameters As IEnumerable(Of Object)) As Object()
```

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `objectId` | [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/) of the object on which the method is to be called. |
| `methodId` | [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/) of the method to call. |
| `parameters` | [IEnumerable](https://learn.microsoft.com/dotnet/api/system.collections.generic.ienumerable-1)&lt;[Object](https://learn.microsoft.com/dotnet/api/system.object)&gt; | A sequence of the values to pass as the input arguments of the method. |

**Returns**

[Object](https://learn.microsoft.com/dotnet/api/system.object)[]

An array of the values of the output arguments returned by the method.

**Exceptions**

| Exception | Condition |
|---|---|
| [ArgumentException](https://learn.microsoft.com/dotnet/api/system.argumentexception) | The `objectId` is a null identifier (see [IsNull](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodeid/members#isnull)). |
| [ArgumentNullException](https://learn.microsoft.com/dotnet/api/system.argumentnullexception) | The `objectId`, `methodId` or `parameters` is a null reference (Nothing in Visual Basic). |

## CallMethod(OpcNodeId, OpcNodeId, params object\[\])

Calls the method identified by the `methodId` on the object identified by the `objectId` specified using the `parameters` as the values of its input arguments.

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

```csharp
public object[] CallMethod(
    OpcNodeId objectId,
    OpcNodeId methodId,
    params object[] parameters)
```

</div>

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

```vbnet
Public Function CallMethod(
    objectId As OpcNodeId,
    methodId As OpcNodeId,
    ParamArray parameters As Object()) As Object()
```

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `objectId` | [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/) of the object on which the method is to be called. |
| `methodId` | [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/) of the method to call. |
| `parameters` | params [Object](https://learn.microsoft.com/dotnet/api/system.object)[] | An array of the values to pass as the input arguments of the method. |

**Returns**

[Object](https://learn.microsoft.com/dotnet/api/system.object)[]

An array of the values of the output arguments returned by the method.

**Exceptions**

| Exception | Condition |
|---|---|
| [ArgumentException](https://learn.microsoft.com/dotnet/api/system.argumentexception) | The `objectId` is a null identifier (see [IsNull](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnodeid/members#isnull)). |
| [ArgumentNullException](https://learn.microsoft.com/dotnet/api/system.argumentnullexception) | The `objectId`, `methodId` or `parameters` is a null reference (Nothing in Visual Basic). |

## CallMethod(OpcCallMethod)

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

Calls the method as defined by the `command` specified.

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

```csharp
public object[] CallMethod(OpcCallMethod command)
```

</div>

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

```vbnet
Public Function CallMethod(command As OpcCallMethod) As Object()
```

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `command` | [OpcCallMethod](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opccallmethod/) | The [OpcCallMethod](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opccallmethod/) command which defines the object, the method and the values of the input arguments of the call. |

**Returns**

[Object](https://learn.microsoft.com/dotnet/api/system.object)[]

An array of the values of the output arguments returned by the method.
