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

Getting a 'Method not found' Error using Connect-PnPOnline #1741

Closed
sdhayward opened this Issue Oct 11, 2018 · 6 comments

Comments

Projects
None yet
4 participants
@sdhayward

sdhayward commented Oct 11, 2018

Reporting an Issue

When I use 'Connect-PnPOnline' to connect to an Online SharePoint Site, it fails and returns a 'Method not found' error.

Expected behavior

Expect to be connected to SharePoint Online

Actual behavior

PS> Connect-PnPOnline -Url $tenancy -Credentials $mySPOCredentials

Connect-PnPOnline : Method not found: 'System.Threading.Tasks.Task Microsoft.SharePoint.Client.ClientRuntimeContext.ExecuteQueryAsync()'.
At line:1 char:1

  • Connect-PnPOnline -Url $tenancy -Credentials $mySPOCredentials
  •   + CategoryInfo          : NotSpecified: (:) [Connect-PnPOnline], MissingMethodException
      + FullyQualifiedErrorId : System.MissingMethodException,SharePointPnP.PowerShell.Commands.Base.ConnectOnline
    
    

Steps to reproduce behavior

PS> Connect-PnPOnline -Url $tenancy -Credentials $mySPOCredentials

where $tenancy is the Tenancy-admin Site and mySPOCredentials are my Online Credentials

Which version of the PnP-PowerShell Cmdlets are you using?

PnP PowerShell for SharePoint Online

What is the version of the Cmdlet module you are running?

PS> Get-Module -Name SharePointPnpPowerShellOnline | select ModuleType, Version, Name

Binary    3.2.1810.0    SharePointPnPPowerShellOnline

How did you install the PnP-PowerShell Cmdlets?

  • MSI Installed downloaded from GitHub
  • Installed through the PowerShell Gallery with Install-Module

I tried both methods (installed using .msi from GitHub and also tried Install-Module).
Also uninstalled and reinstalled latest 'SharePoint Client Components' (Version 16.0.6518.1200).

@jansenbe

This comment has been minimized.

Contributor

jansenbe commented Oct 12, 2018

Do you have the SharePoint client side components SDK also installed on this machine? Can you repro this from a regular client machine?

@sdhayward

This comment has been minimized.

sdhayward commented Oct 12, 2018

Yes, the Client Side Components SDK is installed
Not sure what you mean by "regular client machine"? I also have a Windows 10 Virtual machine and PNP commands work on it. But I built it just for PowerShell and the only things installed on it are various modules (e.g., AzureRM, PnPPowerShell, AD, etc.)

@dougmallen18

This comment has been minimized.

dougmallen18 commented Nov 9, 2018

I have the same issue as well. I had an old 2.x install which has been removed and nothing in GAC that I can tell, but still get issue. Per Erwin, this is the get-pnpexception code for this error:

Message : Method not found: 'System.Threading.Tasks.Task
Microsoft.SharePoint.Client.ClientRuntimeContext.ExecuteQueryAsync()'.
Stacktrace : at
Microsoft.SharePoint.Client.ClientContextExtensions.d__7.MoveNext()
at System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[TStateMachine](TStateMachine&
stateMachine)
at
Microsoft.SharePoint.Client.ClientContextExtensions.ExecuteQueryImplementation(ClientRuntimeContext
clientContext, Int32 retryCount, Int32 delay, String userAgent)
at System.Threading.Tasks.Task`1.InnerInvoke()
at System.Threading.Tasks.Task.Execute()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.SharePoint.Client.ClientContextExtensions.ExecuteQueryRetry(ClientRuntimeContext
clientContext, Int32 retryCount, Int32 delay, String userAgent)
at
SharePointPnP.PowerShell.Commands.Base.SPOnlineConnectionHelper.InstantiateSPOnlineConnection(Uri
url, PSCredential credentials, PSHost host, Boolean currentCredentials, Int32 minimalHealthScore,
Int32 retryCount, Int32 retryWait, Int32 requestTimeout, String tenantAdminUrl, Boolean
disableTelemetry, Boolean skipAdminCheck, ClientAuthenticationMode authenticationMode)
at SharePointPnP.PowerShell.Commands.Base.ConnectOnline.ProcessRecord()
at System.Management.Automation.CommandProcessor.ProcessRecord()
ScriptLineNumber : 1

@gagan2singh

This comment has been minimized.

gagan2singh commented Nov 11, 2018

Hi All,

To resolve the issue, please follow the steps below. Make sure you follow them in the order specified:

  1. Delete all the SharePoint Components from the Control Panel (Add/Remove)
  2. Open the GAC location (C:\windows\Microsoft.NET\assembly\GAC_MSIL), search for the term SharePoint and delete all the folders. (This is required since the reference is still old which is used by the PnP commands)
  3. Re-Start the machine
  4. Install the latest version of the SharePoint PnP

The above steps should resolve the issue.

@dougmallen18

This comment has been minimized.

dougmallen18 commented Nov 11, 2018

I can confirm this resolved the issue. My problem was the files still in the GAC, and I was looking in the wrong assembly folder. I was looking in C:\windows\assembly\GAC_MSIL, not the above path. I reinstalled the Online Mgmt Shell and PnP was already still loaded and it connected just fine.

@sdhayward

This comment has been minimized.

sdhayward commented Nov 12, 2018

@gagan2singh
THANK YOU! THANK YOU! THANK YOU!
This definitely resolved the issue. Followed the instructions and everything worked great. This has gotten in my way for quite a while - I've had to log into Virtual Machines just to run PowerShell & PnP. I might have said this before, but THANK YOU!!!

@sdhayward sdhayward closed this Nov 12, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment