# OpcException Class

<dl class="api-definition">
<dt>Namespace</dt>
<dd><a href="../namespaces/opc.uafx">Opc.UaFx</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">OpcException Members</a></dd>
<dt>Also in</dt>
<dd>Opc.UaFx.Client</dd>
</dl>

The exception that is thrown when an OPC operation has failed.

## Syntax

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

```csharp
public class OpcException : Exception
```

</div>

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

```vbnet
Public Class OpcException
    Inherits Exception
```

</div>

## Inheritance

[Object](https://learn.microsoft.com/dotnet/api/system.object) → [Exception](https://learn.microsoft.com/dotnet/api/system.exception) → **OpcException**

## Implements

<ul class="api-implements">
<li><a href="https://learn.microsoft.com/dotnet/api/system.runtime.serialization.iserializable">ISerializable</a></li>
</ul>

## Constructors

| Name | Description |
|---|---|
| [OpcException](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcexception/members#opcexception)<span class="api-meta">15 overloads</span> | Initializes a new instance of the OpcException class with default properties. |

## Properties

| Name | Description |
|---|---|
| [Code](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcexception/members#code) | Gets the according [OpcStatusCode](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcstatuscode/) for the [ErrorCode](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcexception/members#errorcode). |
| [Context](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcexception/members#context)<span class="api-meta">since v2.11</span> | Gets the [OpcContext](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opccontext/) which was in use while the current OpcException was generated. |
| [Data](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcexception/members#data)<span class="api-meta">override · since v2.7</span> | Gets a collection of key/value pairs that provide additional user-defined information about the exception. |
| [ErrorCode](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcexception/members#errorcode) | Gets the error code of the OpcException. |
| [HelpLink](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcexception/members#helplink)<span class="api-meta">override · since v2.7</span> | Gets or sets a link to the help file associated with this exception. |
| [Message](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcexception/members#message)<span class="api-meta">override</span> | Gets a message that describes the current exception. |
| [Result](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcexception/members#result) | Gets the result information associated with the exception. |
| [Source](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcexception/members#source)<span class="api-meta">override · since v2.7</span> | Gets or sets the name of the application or the object that causes the error. |
| [StackTrace](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcexception/members#stacktrace)<span class="api-meta">override · since v2.7</span> | Gets a string representation of the immediate frames on the call stack. |

## Methods

| Name | Description |
|---|---|
| [GetBaseException](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcexception/members#getbaseexception)<span class="api-meta">override · since v2.8</span> | Returns the System.Exception that is the root cause of one or more subsequent exceptions. |
| [GetObjectData](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcexception/members#getobjectdata)<span class="api-meta">override</span> | Sets the [SerializationInfo](https://learn.microsoft.com/dotnet/api/system.runtime.serialization.serializationinfo) with information about the exception. |
| [ToString](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcexception/members#tostring)<span class="api-meta">override · since v2.8</span> | Creates and returns a string representation of the exception. |

Inherits members from [Exception](https://learn.microsoft.com/dotnet/api/system.exception).

## Applies to

| Package | Versions |
|---|---|
| Opc.UaFx.Advanced | v2.5–v2.59 |
