powershell
powershell copied to clipboard
[BUG] VSCode Move-PnPFile : Method not found: 'Int32 System.Text.Encodings.Web.TextEncoder.FindFirstCharacterToEncodeUtf8(System.ReadOnlySpan1)'.
-
Are you using
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
)
ModuleType Version Name ExportedCommands
---------- ------- ---- ----------------
Manifest 1.5.38 PnP.PowerShell {Add-PnPAlert, Add-PnPApp, Add-PnPApplicationCustomizer, Add-PnPAzureADGroupMember...}
Which operating system/environment are you running PnP PowerShell on?
- [x] Windows
- [ ] Linux
- [ ] MacOS
- [ ] Azure Cloud Shell
- [ ] Azure Functions
- [ ] Other : please specify
Hi @ingepepe , could you please update module? We are already on PnP,PowerShell 1.5.54
Personally I am not able to replicate that issue even on PnP.PowerShell 1.5.42
Could you please also update Title of this request to better reflect the problem?
Just did. Same error.
Sent from my iPhone
On May 26, 2021, at 17:10, Yuriy Samorodov @.***> wrote:
Hi @ingepepehttps://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fingepepe&data=04%7C01%7C%7Cb79d1e16f86f40a06f8308d9209b7886%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637576674376873496%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=Y6MBIv8g1kKm4e4dUlTT3yvtSvpkdbZldceeQuj5vYo%3D&reserved=0 , could you please update module? We are already on PnP,PowerShell 1.5.54 Personally I am not able to replicate that issue even on PnP.PowerShell 1.5.42
Could you please also update Title of this request to better reflect the problem?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fpnp%2Fpowershell%2Fissues%2F727%23issuecomment-849178632&data=04%7C01%7C%7Cb79d1e16f86f40a06f8308d9209b7886%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637576674376883492%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=hHCc7xwOxnAXjz3syDKLEKb32%2Bj0NQWroylMNYuWAQM%3D&reserved=0, or unsubscribehttps://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAN35QEGWDMLIJS3JR7ZTNBTTPV5WXANCNFSM45S2DGLQ&data=04%7C01%7C%7Cb79d1e16f86f40a06f8308d9209b7886%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637576674376893486%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=o%2Fl9tXrtAD%2BpriZQMx1jSZeFxTE5BnER%2FVSqPg6F%2FBM%3D&reserved=0.
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.
I’m using Connect-PnPonline to the source site Ran get-pnplist to make sure I was there
Sent from my iPhone
On May 26, 2021, at 17:23, Yuriy Samorodov @.***> wrote:
Hey @ingepepehttps://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fingepepe&data=04%7C01%7C%7C0ce7359898a44cc0a25c08d9209d56d6%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637576682393319031%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=Q%2BioCcjvsXAfW%2FAs0NXXYy6kA1xlVTuBUElSyCAHQDQ%3D&reserved=0 , could you please confirm endpoint you are connecting to? Please note you have to connect to source site to move files and folders.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fpnp%2Fpowershell%2Fissues%2F727%23issuecomment-849184049&data=04%7C01%7C%7C0ce7359898a44cc0a25c08d9209d56d6%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637576682393329031%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=AA%2FzCFQCYdJJyZrga%2FAJbXosu%2BFh1WISeHY%2FJTNrk2E%3D&reserved=0, or unsubscribehttps://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAN35QEA64NGUNA72KRQWPULTPV7I5ANCNFSM45S2DGLQ&data=04%7C01%7C%7C0ce7359898a44cc0a25c08d9209d56d6%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637576682393329031%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=Xh8JIBI3F9Ko2kaYKLh%2FcBC%2BRQsI%2F8DQwDJazMZ8jDA%3D&reserved=0.
@ingepepe - I'm using 1.5.55-nightly
and have no issue. Please update the module and try again, or try another site.
Also, what is that dot (.) in your target site?
@veronicageek
This is what I get from another site:
VERBOSE: PnP PowerShell Cmdlets (1.5.54.0) PS C:> Move-PnPFile -SourceUrl "/sites/test01/lead/Team Meetings/MyFile.docx" -TargetUrl "/sites/test02/Shared Documents/General" -NoWait -Force -AllowSchemaMismatch -AllowSmallerVersionLimitOnDestination
Move-PnPFile : Method not found: 'Int32 System.Text.Encodings.Web.TextEncoder.FindFirstCharacterToEncodeUtf8(System.ReadOnlySpan`1<Byte>)'. At line:1 char:1
- Move-PnPFile -SourceUrl "/sites/test01/lead/Team Meetings/MyFile.docx ...
-
+ CategoryInfo : WriteError: (:) [Move-PnPFile], MissingMethodException + FullyQualifiedErrorId : EXCEPTION,PnP.PowerShell.Commands.Files.MoveFile
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. I'm still not able to reproduce unfortunately and it's working fine for me.
Let's see if @gautamdsheth / @erwinvanhunen have any ideas / insights.
I've been experiencing a similar issue with a for example Add-PnPPage
. In VSCode I'm getting:
Method not found: "System.Runtime.CompilerServices.ConfiguredValueTaskAwaitable1<Boolean> Enumerator.MoveNextAsync()"
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?
I tried and it worked on PowerShell for Windows (5.1)
Sent from my iPhone
On May 28, 2021, at 03:55, colonelclaypoo @.***> wrote:
I've been experiencing a similar issue with a for example Add-PnPPage. In VSCode I'm getting: Method not found: "System.Runtime.CompilerServices.ConfiguredValueTaskAwaitable1<Boolean> Enumerator.MoveNextAsync()"
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?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHubhttps://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fpnp%2Fpowershell%2Fissues%2F727%23issuecomment-850300946&data=04%7C01%7C%7Cb1875a6bdb364e10285c08d921beb40c%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637577925272385607%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=hf0oRRRk%2B%2FsNsl9H67olDswMT9%2BN0tf4K%2FnWKruWMtI%3D&reserved=0, or unsubscribehttps://na01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAN35QEGZBSIIELIUWFPIYULTP5SAPANCNFSM45S2DGLQ&data=04%7C01%7C%7Cb1875a6bdb364e10285c08d921beb40c%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637577925272385607%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=IG14grLaqAqrh8AOhHR9p40uX54wrQLi6VnXenvNUwI%3D&reserved=0.
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 .net library or sth?
downgrade to 1.5.0 solved it - but why? Without vscode in ise all is fine.
Same if you want to add a security group by id to a communication site Add-PnPGroupMember -Group $spGroupVisitor -LoginName 'c:0t.c|tenant|b6bfb989-98cd-4fcb-95e0-5be17b7bbac0'
Also ran into this issue with Copy-PnPFile and VSCode. Works fine if run outside of VSCode.
Same with Move-PnPFile :) VS Code 1.59
I am having the same issue using Get-PNPListItem in vscode. The error does not exist when running Get-PNPListItem in regular PowerShell.
Steps to reproduce:
- Install-Module PNP.PowerShell -Required Version 1.7.0
When running Get-PNPListItem in vscode an exception is thown:
System.Reflection.TargetInvocationException: Ein Aufrufziel hat einen Ausnahmefehler verursacht. --->
System.MissingMethodException:
Methode nicht gefunden: "Int32 System.Text.Encodings.Web.TextEncoder.FindFirstCharacterToEncodeUtf8(System.ReadOnlySpan`1<Byte>)".
Maybe "System.Text.Encodings.Web.TextEncoder.FindFirstCharacterToEncodeUtf8(System.ReadOnlySpan`1<Byte>)" 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. After this, evertything works fine, no error vscode.
So it seems like the error does not exist in PNP.PowerShell 1.5.0 but in version 1.7.0. And it is only thrown usin vscode powershell.
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.
See: https://github.com/PowerShell/vscode-powershell/issues/3510
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.
Set-PnPListItem : Method not found : 'Void Microsoft.SharePoint.Client.ListItem.SetComplianceTag
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
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.
Running $PSVersionTable
will show the same Powershell version though. (In vscode terminal / vscode integrated terminal / windows terminal)
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 ? The v2 supports only PowerShell 7.2 or later versions .
Closing this issue now. Since v2.1.1 , PnP PowerShell is fully on .NET 6, so we have dropped support for PS5.1 or ISE. If the issue still exists, please feel free to reopen it.