Today I faced my second problem when working with the new Vault 2014 SDK Now, and because an other customer had the same issue, I want to give the solution to everyone.
Problem 1: Creating Vault Connection object
Creating the Vault Connection object is very easy with the new VDF. There is a nice way to create the connection via a login function that brings up a login-dialog for you. But what I needed (and also a customer) was a function where you can pass in all the login creadentials.
Actually we where using the old way to create the webservicemanager and than we created the connection object via its constructor:
This way is defenetly the wrong way!!! You can read it also in the sdk-dokumentation:
” …it attatches to an existing low level connection to the server”. This description is not very helpful, but there is a better solution:
var loginResult=Autodesk.DataManagement.Client.Framework.Vault.Library.ConnectionManager.LogIn(serverName, vaultName, userName,password, AuthenticationFlags.Standard, null);
var vaultConnection = loginResult.Connection;
Why are we using this way?
I realized very late that the other way brings up different problems. The issue that I faced was creating the ExplorerUtils object with the ticket from the connection. When I used the wrong way, the explorerUtil object was created, but UpdateFileProperties run into this error (all the parameters where correct):
Problem 2: Errors when calling API functions out from PowerShell
This problem seems to me like an API bug. When we create a VisualStudio program that connects to vault and uses functions like AddFolder, everything works well. But when we run the same code inside PowerShell we get this error message:
Exception calling "AddFolder" with "3" argument(s): "Unable to find assembly 'Autodesk.Connectivity.WebServices, Version=188.8.131.52, Culture=neutral, PublicKeyToken=aa20f34aedd220e1'."
At line:19 char:74
+ $newFolder = $vaultConnection.WebServiceManager.DocumentService.AddFolder <<<< ("Test2",$rootFolder.Id,$false)
+ CategoryInfo : NotSpecified: (:) , MethodInvocationException
+ FullyQualifiedErrorId : DotNetMethodException
Using FusionLogViewer you can see that an assembly called Webservices.Serializers was not found. This assembly was there only in vault 2013 SDK, but not in Vault 2014!
Run this code to reproduce the problem:
[System.Reflection.Assembly]::LoadFrom("C:\Program Files\Autodesk\Vault Professional 2014\Explorer\Autodesk.Connectivity.WebServices.dll")
[System.Reflection.Assembly]::LoadFrom("C:\Program Files\Autodesk\Vault Professional 2014\Explorer\Autodesk.Connectivity.Explorer.Extensibility.dll")
[System.Reflection.Assembly]::LoadFrom("C:\Program Files\Autodesk\Vault Professional 2014\Explorer\Autodesk.Connectivity.Explorer.ExtensibilityTools.dll")
[System.Reflection.Assembly]::LoadFrom("C:\Program Files\Autodesk\Vault Professional 2014\Explorer\Autodesk.Connectivity.Extensibility.Framework.dll")
[System.Reflection.Assembly]::LoadFrom("C:\Program Files\Autodesk\Vault Professional 2014\Explorer\Autodesk.DataManagement.Client.Framework.dll")
[System.Reflection.Assembly]::LoadFrom("C:\Program Files\Autodesk\Vault Professional 2014\Explorer\Autodesk.DataManagement.Client.Framework.Forms.dll")
[System.Reflection.Assembly]::LoadFrom("C:\Program Files\Autodesk\Vault Professional 2014\Explorer\Autodesk.DataManagement.Client.Framework.Vault.dll")
[System.Reflection.Assembly]::LoadFrom("C:\Program Files\Autodesk\Vault Professional 2014\Explorer\Autodesk.DataManagement.Client.Framework.Vault.Forms.dll")
$loginResult=[Autodesk.DataManagement.Client.Framework.Vault.Library]::ConnectionManager.LogIn("10.0.0.148", "Vault", "Administrator","",[Autodesk.DataManagement.Client.Framework.Vault.Currency.Connections.AuthenticationFlags]::Standard, $null);
$vaultConnection = $loginResult.Connection;
$rootFolder = $vaultConnection.FolderManager.RootFolder
$newFolder = $vaultConnection.WebServiceManager.DocumentService.AddFolder("Test",$rootFolder.Id,$false)
AddFolder will fail with the error message!
How to solve the problem?
There are to possibilities:
- call LoadExplorerUtil after creating the connection to vault:
$explorerUtil=[Autodesk.Connectivity.Explorer.ExtensibilityTools.ExplorerLoader]::LoadExplorerUtil($vaultConnection.Server, $vaultConnection.Vault, $vaultConnection.UserID, $vaultConnection.Ticket)
This function will load a lot of assemblies from your Vault client in the background. Now all the assemblies can be found.
- use powerJobs2014 SDK:
This is the simplest way when running in powerShell. Just call this two lines in your PowerGui and you have access to $vault, $vaultConnection, $explorerUtils,… PowerJobs will create all this variables automatically in your powerShell environment!
I hope this was helpful for some vault developer like me I know that in any case it would have been helpful for our customer who faced this problems this morning