Vscode-powershell: Get-PowerBIWorkspace : Attempted to access an element as a type incompatible with the array

Created on 1 Aug 2019  路  13Comments  路  Source: PowerShell/vscode-powershell

Issue Description

I'm receiving the following error when trying to use the Get-PowerBIWorkspace cmdlet in VS Code & Azure Data Studio:

Get-PowerBIWorkspace : Attempted to access an element as a type incompatible with the array.
At line:1 char:1

I do not receive this error when running the exact same command in the ISE or PowerShell.exe, and I can reproduce these results on multiple machines.

System Details

  • Operating system: Windows 7
  • Azure Data Studio version 1.9.0 (system setup) - July 10th build (monthly release).
  • PowerShell extension version 2019.5.0
  • Output from $PSVersionTable 5.1.14409.1018

Full error message

PS C:\temp> Get-PowerBIWorkspace
Get-PowerBIWorkspace : Attempted to access an element as a type incompatible with the array.
At line:1 char:1
+ Get-PowerBIWorkspace
+ ~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : WriteError: (Microsoft.Power...owerBIWorkspace:GetPowerBIWorkspace) [Get-PowerBIWorkspace], ArrayTypeMismatchException
    + FullyQualifiedErrorId : Attempted to access an element as a type incompatible with the array.,Microsoft.PowerBI.Commands.Workspaces.GetPowerBIWorkspace

Needs-Repro-Info Resolution - Inactive

Most helpful comment

@SQLvariant agreed that it would be nice for module authors to know which versions of Newtonsoft they should use as this can be a very complicated issue...might be best to open an issue in PowerShell/PowerShell on how to handle C# module dependency management

All 13 comments

@SQLvariant thanks for reporting this issue, interestingly I can only repro in Windows PowerShell in VSCode/ADS

@SQLvariant can you supply the full stack trace of the above error. You should be able to drill down into $error[0] after getting that error

I can repro this error as well.

@SQLvariant can you supply the full stack trace of the above error. You should be able to drill down into $error[0] after getting that error

Robert,
I can't post the result here, but I could send it to you privately, if that works?

I can't post the result here, but I could send it to you privately, if that works?

Sure - you can send it through to [email protected]

It appears that the issue is caused by the version of the Newtonsoft.Json DLL being outdated (relative to what the PowerBI modules require).

Our Newtonsoft.Json version is constrained by PowerShell Core's Newtonsoft.Json version -- they must match.

So our code can link and work cross platform, we ship the same version in PowerShell Editor Services for Windows PowerShell.

You might be able to circumvent this by adding an Add-Type in the Start-EditorServices.ps1 before any others targeting the Newtonsoft.Json.dll version you need.

Looks like this issue is also being tracked at https://github.com/microsoft/powerbi-powershell/issues/60 their recommendation is to use PowerShell Core

This issue is being closed as inactive, if this issue is still occurring it will be re-opened

Bot is a bit trigger happy...

This issue is being closed as inactive, if this issue is still occurring it will be re-opened

@TylerLeonhardt Can we provide module builders with some [easier to find] official guidance on which version of Newtonsoft they should use in order to avoid this?

Even if we just put a link to the official guidance in this issue, that will make it easier to find when someone searches for the error message.

@SQLvariant agreed that it would be nice for module authors to know which versions of Newtonsoft they should use as this can be a very complicated issue...might be best to open an issue in PowerShell/PowerShell on how to handle C# module dependency management

Was this page helpful?
0 / 5 - 0 ratings

Related issues

GQnzo picture GQnzo  路  3Comments

daviwil picture daviwil  路  4Comments

MiYanni picture MiYanni  路  3Comments

AWahlqvist picture AWahlqvist  路  3Comments

rkeithhill picture rkeithhill  路  3Comments