-
Notifications
You must be signed in to change notification settings - Fork 328
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] VSCode Move-PnPFile : Method not found: 'Int32 System.Text.Encodings.Web.TextEncoder.FindFirstCharacterToEncodeUtf8(System.ReadOnlySpan1)'. #727
Comments
Hi @ingepepe , could you please update module? We are already on Could you please also update Title of this request to better reflect the problem? |
Hey @ingepepe , could you please confirm endpoint you are connecting to? Please note you have to connect to source site to move files and folders. |
@ingepepe - I'm using Also, what is that dot (.) in your target site? |
This is what I get from another site: VERBOSE: PnP PowerShell Cmdlets (1.5.54.0) Move-PnPFile : Method not found: 'Int32 System.Text.Encodings.Web.TextEncoder.FindFirstCharacterToEncodeUtf8(System.ReadOnlySpan`1)'.
|
Not sure if it has to do with the fact that I'm executing it from VS Code? |
@ingepepe - I don't think VSCode is not an issue as I've been able to successfully run your code. Let's see if @gautamdsheth / @erwinvanhunen have any ideas / insights. |
I've been experiencing a similar issue with a for example Using 1.5.55-nightly. It works fine in PowerShell 5 and 7 standalone console. So it might be VSCode related after all what do you think? |
This issue is stale because it has been open 14 days with no activity. Remove stale label or comment or this will be closed in 5 days |
I had the same exact issue with different command-lets. Ended up downgrading to 1.5.0 and issue went away. What was really strange that I did not have any issues running it from powershell prompt or PS ISE. |
It's unfortunate but I can confirm your two statements @SergeiAtML. Ended up downgrading as well on one machine end try to use the PowerShell 7 default shell when necessarily have to make use of a newer version than 1.5.0. |
I can also confirm that downgrading to 1.5.0 resolves the issue in VSCode (mine was with the Add-PnPGroupMember cmdlet). |
What has been done in 1.6.0 / 1.7.0 from 1.5.0 with the downgrade to 1.5.0 solved it - but why? Same if you want to add a security group by id to a communication site |
Also ran into this issue with Copy-PnPFile and VSCode. Works fine if run outside of VSCode. |
Same with Move-PnPFile :) |
I am having the same issue using Get-PNPListItem in vscode. Steps to reproduce:
Maybe "System.Text.Encodings.Web.TextEncoder.FindFirstCharacterToEncodeUtf8(System.ReadOnlySpan`1)" indicates a type-mismatch in source-code somewhere ? I then call Uninstall-Module PNP.PowerShell followed by Install-Module PNP.PowerShell -RequiredVersion 1.5.0. So it seems like the error does not exist in PNP.PowerShell 1.5.0 but in version 1.7.0. |
Repeating ping but over here... @KoenZomers and @gautamdsheth are you two also looking at this? It seems to have been introduced when a custom ALC with a resolver was added to PNP.PowerShell, and it's not expecting another ALC (the one in Editor Services) to exist and possibly resolve dependencies. But we're still not entirely sure. |
Try running it in regular VS Code terminal, not in the PowerShell Integrated Console. I had a similar issue with Add-PnPApp and it works on the regular terminal. If you check the versions of the 2 consoles running Get-Host | Select-Object Version, regular console is 5.1.18362.1801, whereas the PowerShell Integrated Console is 2021.9.0. |
Hi, I started having the same issue on Set-PnPListItem after upgrading to 1.7.0 on a regular PS console. Downgrading to 1.6.0 solves the issue. |
I'm having the same issue with Add-PnPGroupMember (PnP PowerShell 1.7.0) in vs code (1.60.2) Integrated Terminal. Add-PnPGroupMember : Method not found: 'Int32 System.Text.Encodings.Web.TextEncoder.FindFirstCharacterToEncodeUtf8(System.ReadOnlySpan`1<Byte>)' Issue 'solved' when running the command from Windows Terminal > PowerShell Window |
Running |
I think we have tracked this down to a broken scenario where PnP-PowerShell requests a dependency of a different version than the Code extension's Editor Services PowerShell module. With PowerShell Core, this isn't a problem because of the isolated assembly load contexts; however, when using Windows PowerShell (AKA PowerShell 5.1), the existence of the .NET Framework's GAC causes this bug. I am unsure if there's a solution (the "work-around" is to use the modern PowerShell 7 which utilizes .NET Core's assembly load contexts to prevent these kinds of bugs). |
Yeah PS7 is the way to go. Not sure we can do anything from our side here. If you have any ideas , please let us know. Happy to fix it. But as long as it works in PS7 and PS5, it should cover majority of the scenarios. We ran into some trouble because of Az module issues, tried to fix it but looks like that broke VS code executions. |
Theoretically if PnP.PowerShell updated the troublesome dependenc(ies) to the same version that Editor Services uses, it would work, but that's a fragile fix because it's starting to look like there's more than one assembly at play. In short: these bugs are due to the GAC. The problem was fixed with .NET Core. Windows PowerShell by definition is not PowerShell Core and therefore does not use .NET Core, but the desktop .NET Framework, where the GAC still reigns supreme. Unless someone knows a workaround with the GAC, I think we're up a creek without a paddle for this scenario. @rjmholt would you concur? |
@andschwa , @ingepepe - we have updated quite a few dependencies in the latest nightly builds as part of prep for an upcoming v2, maybe it fixes the issue ? To test it, you can download the latest nightly builds and maybe let us know if the issue still persists ? |
Closing this issue now. |
Invoke-PnPSiteTemplate
orGet-PnPSiteTemplate
?No
Reporting an Issue or Missing Feature
When trying to execute the command
Move-PnPFile -SourceUrl "/sites/Leadership-365/Shared Documents/Regional Managers" -TargetUrl "/sites/operations.leaders/Shared Documents" -AllowSchemaMismatch
I get the following error:
Move-PnPFile : Method not found: 'Int32 System.Text.Encodings.Web.TextEncoder.FindFirstCharacterToEncodeUtf8(System.ReadOnlySpan1)'.
What is this error about?
Expected behavior
Run the cmdlet
Actual behavior
Error: Method not Found
Steps to reproduce behavior
When trying to execute the command
Move-PnPFile -SourceUrl "/sites/Leadership-365/Shared Documents/Regional Managers" -TargetUrl "/sites/operations.leaders/Shared Documents" -AllowSchemaMismatch
I get the following error:
Move-PnPFile : Method not found: 'Int32 System.Text.Encodings.Web.TextEncoder.FindFirstCharacterToEncodeUtf8(System.ReadOnlySpan1)'.
What is the version of the Cmdlet module you are running?
(you can retrieve this by executing
Get-Module -Name "PnP.PowerShell" -ListAvailable
)Which operating system/environment are you running PnP PowerShell on?
The text was updated successfully, but these errors were encountered: