PowerEvents throws warnings when events are triggered in a Vault console application

When using powerEvents in a Vault console application connection warnings are displayed. "VaultConnectionFactory.GetConnection ... Object reference not set to an instance of an object"

Issue

When events are triggered in a Vault console application, on a computer that also has powerEvents(PE) installed the PE scripts are not executed. Instead warnings are displayed similar to the below.

WARN  powerEvents.Cmdlets.Vault.VaultConnectionFactory -   VaultConnectionFactory.GetConnection({Autodesk.Connectivity.WebServices.DocumentService}) | Failed, exception = {NullReferenceException}.

WARN  powerEvents.Cmdlets.Vault.VaultEventBase`2+MappedVaultEvent - MappedVaultEvent.InitializeVaultConnection({Autodesk.Connectivity.WebServices.DocumentService}) | Failed, exception = {NullReferenceException}.

Cause

Issue only occurs in version v22.

Solution 1

This issue was fixed in powerEvents v23.0.1. Install at least powerEvents v23.0.1.

Solution 2

  • In your solution add a reference to "C:\Program Files\Autodesk\Vault Client 2022\Explorer\Connectivity.Application.VaultBase.dll"
  • After creating your connection make sure to set Connectivity.Application.VaultBase.ConnectionManager.Instance.Connection to your connection object
ServerIdentities serverIdentity = new ServerIdentities
{
    DataServer = "127.0.0.1",
    FileServer = "127.0.0.1"
};
string vaultName = "Vault";
string userName = "Administrator";
string password = "";
LicensingAgent licensingAgent = LicensingAgent.Client;
    
var loginResult = Library.ConnectionManager.LogIn(serverIdentity.DataServer, vaultName, userName, password, AuthenticationFlags.Standard, null);
Connectivity.Application.VaultBase.ConnectionManager.Instance.Connection = loginResult.Connection;

var userPasswordCredentials = new UserPasswordCredentials(serverIdentity, vaultName, userName, password, licensingAgent);
var Vault = new WebServiceManager(userPasswordCredentials);

Solution 3

If you are addressing Vault 2020 or Vault 2021 you can simply downgrade your powerEvents installation to version 21.0.7 as the issue only occurs in v22.0 and later.

Remarks

If you get an error about a missing "Autodesk.DataManagement.Client.Framework.Forms" you also have to add that reference to your solution