# IOpcApplicationInstance Members

> Reference: Defines a concrete application of one of the possible OPC UA application types available.

<dl class="api-definition">
<dt>Type</dt>
<dd><a href="./">IOpcApplicationInstance</a></dd>
<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>Also in</dt>
<dd>Opc.UaFx.Client</dd>
</dl>

## Properties

### ApplicationName

Gets or sets the name of the application instance.

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

```csharp
string ApplicationName { get; set; }
```

</div>

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

```vbnet
Property ApplicationName As String
```

</div>

**Property value**

[String](https://learn.microsoft.com/dotnet/api/system.string)

The name of the application. The default value is "OPC Application" in case there is no entry assembly available; otherwise the value of the [AssemblyTitleAttribute](https://learn.microsoft.com/dotnet/api/system.reflection.assemblytitleattribute) of the entry assembly.

**Remarks**

The name does not have to be unique. The value of this property is also used as the [SubjectName](https://learn.microsoft.com/dotnet/api/system.security.cryptography.x509certificates.x509certificate2.subjectname) of the application certificate whenever an application certificate is to be created/looked-up (from the application certificates store).

### ApplicationState

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

Gets the current state of the application instance.

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

```csharp
OpcApplicationState ApplicationState { get; }
```

</div>

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

```vbnet
ReadOnly Property ApplicationState As OpcApplicationState
```

</div>

**Property value**

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

One of the members defined by the [OpcApplicationState](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcapplicationstate/) enumeration.

### ApplicationType

Gets the type of application the instance represents.

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

```csharp
OpcApplicationType ApplicationType { get; }
```

</div>

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

```vbnet
ReadOnly Property ApplicationType As OpcApplicationType
```

</div>

**Property value**

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

One of the members defined by the [OpcApplicationType](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcapplicationtype/) enumeration. Each member identifies a specific type of OPC UA application and its usage within the OPC UA environment.

### ApplicationUri

Gets or sets the URI of the application instance.

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

```csharp
Uri ApplicationUri { get; set; }
```

</div>

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

```vbnet
Property ApplicationUri As Uri
```

</div>

**Property value**

[Uri](https://learn.microsoft.com/dotnet/api/system.uri)

The [Uri](https://learn.microsoft.com/dotnet/api/system.uri) or a null reference (Nothing in Visual Basic) which uniquely identifies the application instance.

**Remarks**

In case there the value of this property is a null reference (Nothing in Visual Basic) the URI of the application is determined by the subject alternate name of the application certificate used. In case there an application certificate is to be created, this value is used to define the certificates subject alternate name.

### Certificate

Gets or sets the application certificate representing the applications identity.

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

```csharp
X509Certificate2 Certificate { get; set; }
```

</div>

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

```vbnet
Property Certificate As X509Certificate2
```

</div>

**Property value**

[X509Certificate2](https://learn.microsoft.com/dotnet/api/system.security.cryptography.x509certificates.x509certificate2)

An instance of the [X509Certificate2](https://learn.microsoft.com/dotnet/api/system.security.cryptography.x509certificates.x509certificate2) class used to identify the application instance.

### CertificateStores

Gets the [OpcCertificateStores](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opccertificatestores/) instance used to maintain the different certificate stores used by the application instance.

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

```csharp
OpcCertificateStores CertificateStores { get; }
```

</div>

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

```vbnet
ReadOnly Property CertificateStores As OpcCertificateStores
```

</div>

**Property value**

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

An instance of the [OpcCertificateStores](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opccertificatestores/) class used by the instance to setup and maintain the certificate stores and their certificates used by the application instance.

### Configuration

Gets or sets an instance of the [OpcApplicationConfiguration](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcapplicationconfiguration/) class which is used as a low-level representation of the code/file based application instance configuration.

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

```csharp
OpcApplicationConfiguration Configuration { get; set; }
```

</div>

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

```vbnet
Property Configuration As OpcApplicationConfiguration
```

</div>

**Property value**

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

An instance of the [OpcApplicationConfiguration](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcapplicationconfiguration/) class configured with the instance specific setup to use. An assignment of a null reference (Nothing in Visual Basic) will lead to the creation of a new instance of the [OpcApplicationConfiguration](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcapplicationconfiguration/) class with all defaults typically used by the type of application instance.

### Namespaces

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

Gets a read-only collection of namespaces used by the application instance.

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

```csharp
OpcReadOnlyNamespaceCollection Namespaces { get; }
```

</div>

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

```vbnet
ReadOnly Property Namespaces As OpcReadOnlyNamespaceCollection
```

</div>

**Property value**

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

An instance of the [OpcReadOnlyNamespaceCollection](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcreadonlynamespacecollection/) class with [OpcNamespace](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcnamespace/) items for each 'NamespaceUri' known/used.

### ProductUri

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

Gets or sets the URI of the product.

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

```csharp
Uri ProductUri { get; set; }
```

</div>

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

```vbnet
Property ProductUri As Uri
```

</div>

**Property value**

[Uri](https://learn.microsoft.com/dotnet/api/system.uri)

The [Uri](https://learn.microsoft.com/dotnet/api/system.uri) or a null reference (Nothing in Visual Basic) which uniquely identifies the product.

**Remarks**

In case there the value of this property is a null reference (Nothing in Visual Basic) the URI of the product is determined by the [AssemblyCompanyAttribute](https://learn.microsoft.com/dotnet/api/system.reflection.assemblycompanyattribute) and [AssemblyProductAttribute](https://learn.microsoft.com/dotnet/api/system.reflection.assemblyproductattribute) used.

### Security

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

Gets the [OpcSecurity](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcsecurity/) instance used to maintain the different security options used by the application instance.

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

```csharp
OpcSecurity Security { get; }
```

</div>

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

```vbnet
ReadOnly Property Security As OpcSecurity
```

</div>

**Property value**

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

An instance of the [OpcSecurity](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opcsecurity/) class used by the [IOpcApplicationInstance](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.iopcapplicationinstance/) to setup and maintain the different security options.

### SystemContext

<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 is used to store the context sensitive data and configuration used by the current application instance.

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

```csharp
OpcContext SystemContext { get; }
```

</div>

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

```vbnet
ReadOnly Property SystemContext As OpcContext
```

</div>

**Property value**

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

An instance of the [OpcContext](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opccontext/) class which might be at least [Empty](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opccontext/members#empty).

### Transport

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

Gets the [OpcTransport](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opctransport/) instance used to maintain the different transport options used by the application instance.

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

```csharp
OpcTransport Transport { get; }
```

</div>

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

```vbnet
ReadOnly Property Transport As OpcTransport
```

</div>

**Property value**

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

An instance of the [OpcTransport](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opctransport/) class used by the [IOpcApplicationInstance](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.iopcapplicationinstance/) to setup and maintain the different transport options.

## Methods

### QueryCertificate

Requests the certificate to use for this application instance in case there the certificate could not automatically determined using the information of this application instance or there are any issues with the [Certificate](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.iopcapplicationinstance/members#certificate).

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

```csharp
X509Certificate2 QueryCertificate(OpcCertificateValidationResult reason)
```

</div>

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

```vbnet
Function QueryCertificate(
    reason As OpcCertificateValidationResult) As X509Certificate2
```

</div>

**Parameters**

| Name | Type | Description |
|---|---|---|
| `reason` | [OpcCertificateValidationResult](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opccertificatevalidationresult/) | One of the members defined by the [OpcCertificateValidationResult](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opccertificatevalidationresult/) enumeration indicating the reason upon that the certificate could not automatically determined or indicating which issue with the [Certificate](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.iopcapplicationinstance/members#certificate) exists. |

**Returns**

[X509Certificate2](https://learn.microsoft.com/dotnet/api/system.security.cryptography.x509certificates.x509certificate2)

An instance of the [X509Certificate2](https://learn.microsoft.com/dotnet/api/system.security.cryptography.x509certificates.x509certificate2) class indicating the application instance certificate to use or a null reference (Nothing in Visual Basic) in case there the framework shall create a new certificate by its own using the application information of this instance.

## Events

### CertificateRequested

Occurs when the certificate of this application instance could not automatically determined using the information of this [IOpcApplicationInstance](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.iopcapplicationinstance/). This event is when used to query the certificate to use for the application instance. Additionally use this event to determine the case that an appropriate instance certificate is missing and in case there [AutoCreateCertificate](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opccertificatestores/members#autocreatecertificate) of [CertificateStores](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.iopcapplicationinstance/members#certificatestores) is equals true a new certificate is being created automatically after the event has been processed (and this may take some time).

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

```csharp
event OpcCertificateRequestedEventHandler CertificateRequested
```

</div>

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

```vbnet
Event CertificateRequested As OpcCertificateRequestedEventHandler
```

</div>

**Event type**

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

**Remarks**

The event occurs when a server starts or a client connects, with one of the following [Reason](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opccertificaterequestedeventargs/members#reason) values:

- [Missing](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opccertificatevalidationresult/#missing), [MissingPrivateKey](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opccertificatevalidationresult/#missingprivatekey), [InvalidThumbrint](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opccertificatevalidationresult/#invalidthumbrint), [MissingApplicationUri](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opccertificatevalidationresult/#missingapplicationuri) and, for a server, [InvalidDomain](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opccertificatevalidationresult/#invaliddomain): the certificate cannot be used. A new certificate is created if [AutoCreateCertificate](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opccertificaterequestedeventargs/members#autocreatecertificate) is true and [AlternativeCertificate](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opccertificaterequestedeventargs/members#alternativecertificate) is a null reference (Nothing in Visual Basic). Another certificate provided using [AlternativeCertificate](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opccertificaterequestedeventargs/members#alternativecertificate) is used instead.
- [Invalid](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opccertificatevalidationresult/#invalid), [UseNotAllowed](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opccertificatevalidationresult/#usenotallowed), [Revoked](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opccertificatevalidationresult/#revoked), [TimeInvalid](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opccertificatevalidationresult/#timeinvalid), [IssuerUseNotAllowed](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opccertificatevalidationresult/#issuerusenotallowed), [IssuerRevoked](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opccertificatevalidationresult/#issuerrevoked) and [IssuerTimeInvalid](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opccertificatevalidationresult/#issuertimeinvalid): the certificate exists, but other applications refuse it (e.g. because it has expired). The certificate is never replaced automatically: if [AlternativeCertificate](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opccertificaterequestedeventargs/members#alternativecertificate) is a null reference (Nothing in Visual Basic) or the original certificate, the application keeps using it; another certificate provided using [AlternativeCertificate](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opccertificaterequestedeventargs/members#alternativecertificate) is used instead.

A certificate which is not trusted yet does not raise the event; it is added to the [TrustedPeerStore](https://www.traeger.de/en/docs/development/opcua/api/v2.59/opc.uafx.opccertificatestores/members#trustedpeerstore).

### CertificateValidationFailed

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

Occurs when the validation of a opponent application instance certificate does not fulfill the requirements for valid and trusted certificates.

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

```csharp
event OpcCertificateValidationFailedEventHandler CertificateValidationFailed
```

</div>

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

```vbnet
Event CertificateValidationFailed As OpcCertificateValidationFailedEventHandler
```

</div>

**Event type**

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

**Remarks**

This event can be used to complement the default validation of opponent application instance certificates. Using the event arguments it is possible to accept the certificate using different/custom circumstances.
