Accessing a powerVault file object property results in error "Object reference not set to an instance of an object."

When accessing reference to an old file object all values are null pointers

Issue

When accessing any property of a powerVault file object the error "Object reference not set to an instance of an object." is displayed. When looking at the object in the inspector all of that object's properties are marked with the same error message.

Cause

In some situations, when making a new reference to the same file, it can happen that the old reference becomes stale. 

For example in the below code the reference stored in $_updatePdf_Engineering becomes stale after a new reference to the same file is stored in $_updatePdf_Office

$PDFfile = Add-VaultFile -From C:\TEMP\Test.pdf -To '$/Designs/Test.pdf' -FileClassification None
$update1Pdf = Update-VaultFile -File $PDFfile._FullPath -Category "Engineering"
$update2Pdf = Update-VaultFile -File $PDFfile._FullPath -Category "Office"

Solution

The workaround for this issue is to access the most recent reference. In the example above this would be $_update2Pdf._Name instead of $_update1Pdf

$PDFfile = Add-VaultFile -From C:\TEMP\Test.pdf -To '$/Designs/Test.pdf' -FileClassification None
$update1Pdf = Update-VaultFile -File $PDFfile._FullPath -Category "Engineering"
$update2Pdf = Update-VaultFile -File $PDFfile._FullPath -Category "Office"

$update1Pdf._Name # Object reference not set to an instance of an object.
$update2Pdf._Name # Test.pdf