Skip to content
This repository has been archived by the owner on Aug 24, 2021. It is now read-only.

Missing Method exception on Extracting Objects of Type ObjectListInstance #1121

Closed
maerger opened this issue Aug 6, 2015 · 8 comments
Closed

Comments

@maerger
Copy link

maerger commented Aug 6, 2015

Hi

I just downloaded the latest version compiled with Debug15 settings and tried to xml extract a SP Site (SP 2013 on-prem) using powershell:
Get-SPOProvisioningTemplate -Out c:\temp\template.xml

Unfortunately I always get an error message when the command tries to extract items of type ObjectListInstance.

After Debugging I get the Error in
...\Framework\Provisioning\ObjectHandlers\SiteToTemplateConversion.cs Line 74

Error text:
Get-SPOProvisioningTemplate : Methode nicht gefunden: "Int32 Microsoft.SharePoint.Client.List.get_MajorWithMinorVersionsLimit()".
In Zeile:1 Zeichen:1

  • Get-SPOProvisioningTemplate -Out c:\temp\template.xml
  • - CategoryInfo          : WriteError: (:) [Get-SPOProvisioningTemplate], MissingMethodException
    - FullyQualifiedErrorId : EXCEPTION,OfficeDevPnP.PowerShell.Commands.Branding.GetProvisioningTemplate
    
    

StackTrace:
bei OfficeDevPnP.Core.Framework.Provisioning.ObjectHandlers.ObjectListInstance.ExtractObjects(Web web, ProvisioningTemplate template, ProvisioningTemplateCreationInformation creationInfo)
bei OfficeDevPnP.Core.Framework.Provisioning.ObjectHandlers.SiteToTemplateConversion.GetRemoteTemplate(Web web, ProvisioningTemplateCreationInformation creationInfo)
bei Microsoft.SharePoint.Client.WebExtensions.GetProvisioningTemplate(Web web, ProvisioningTemplateCreationInformation creationInfo)
bei OfficeDevPnP.PowerShell.Commands.Branding.GetProvisioningTemplate.GetProvisioningTemplateXML(XMLPnPSchemaVersion schema, String path)
bei OfficeDevPnP.PowerShell.Commands.Branding.GetProvisioningTemplate.ExecuteCmdlet()
bei OfficeDevPnP.PowerShell.Commands.SPOCmdlet.ProcessRecord()

Can anybody help?

Thanks
Roman

@erwinvanhunen
Copy link
Member

In your source, check the ObjectListinstance.cs class in Framework\Provisioning\ObjectHandlers, on line 425 it should say:

#if !CLIENTSDKV15
, l => l.MajorWithMinorVersionsLimit
#endif
);

If not, you have an older version of the code somehow. Make sure that if you switch to the Debug15 configuration that those lines are greyed out. If not, visual studio is not applying the preprocessor variables.

@maerger
Copy link
Author

maerger commented Aug 7, 2015

There is one:
image

And it seems to not beeing compiled in "Debug15" configuration.
Could it be due to missing updates on my Sharepoint Server?

@erwinvanhunen
Copy link
Member

That seems okay, from a code perspective, it should not call the MajorWithMinorVersionsLimit method, as that one is not available on-premises. That's what the Debug15 (and Release15) configuration basically is for. So all good there.

In your own built version, where do you install it? Do you have other versions of the PnP cmdlets installed and if so, which one is powershell using? In the installation folder of the cmdlets there should be a OfficeDevPnP.Core.dll. Did you replace that one with your compiled version?

PowerShell will figure out which module to use by checking the folders as defined in the PSModulePath environment variable (check that one out through PowerShell with "$env:PSModulePath").

@maerger
Copy link
Author

maerger commented Aug 11, 2015

Just cleaned my environment - performed the latest SP updates - recompiled the code using the Debug15 and copied the dll's manually to the installed version but still the same error message.

Debugging powershell added a breakpoint here (SiteToTemplateConversion.cs):
image

I just wonder why this breakpoint into the ObjectListInstance.cs is never hit:

image

Here's the exception detail:
System.MissingMethodException was caught
HResult=-2146233069
Message=Methode nicht gefunden: "Int32 Microsoft.SharePoint.Client.List.get_MajorWithMinorVersionsLimit()".
Source=OfficeDevPnP.Core
StackTrace:
bei OfficeDevPnP.Core.Framework.Provisioning.ObjectHandlers.ObjectListInstance.ExtractObjects(Web web, ProvisioningTemplate template, ProvisioningTemplateCreationInformation creationInfo)
bei OfficeDevPnP.Core.Framework.Provisioning.ObjectHandlers.SiteToTemplateConversion.GetRemoteTemplate(Web web, ProvisioningTemplateCreationInformation creationInfo)
bei Microsoft.SharePoint.Client.WebExtensions.GetProvisioningTemplate(Web web, ProvisioningTemplateCreationInformation creationInfo)
bei OfficeDevPnP.PowerShell.Commands.Branding.GetProvisioningTemplate.GetProvisioningTemplateXML(XMLPnPSchemaVersion schema, String path)
bei OfficeDevPnP.PowerShell.Commands.Branding.GetProvisioningTemplate.ExecuteCmdlet()
bei OfficeDevPnP.PowerShell.Commands.SPOCmdlet.ProcessRecord()
InnerException:

@erwinvanhunen
Copy link
Member

If the breakpoint is not resolving, it means that you're using a different assembly from the one you have open in Visual Studio. Did you check the value of your PSModulePath environment variable? Make sure there is only one folder in there which contains the actual PnP PowerShell assemblies. If you for instance installed the version from the MSI package first and -then- use the version which is compiled by visual studio you will end up with 2 entries in that variable:

one pointing to c:\users\Documents\WindowsPowerShell\Modules\etc.
one pointing to either
c:\users\AppData\Local\Apps\OfficeDevPnP\etc.
or
c:\program files (x86)\OfficeDevPnP\etc.

Make sure that only c:\users\Documents\WindowsPowerShell\Modules\etc is in there as that is the version that the visual studio solution deploys.

@maerger
Copy link
Author

maerger commented Aug 11, 2015

I have a bunch of module paths also used by other modules but the pnp dll's are just found here:
C:\Users\AppData\Local\Apps\OfficeDevPnP.PowerShell.Commands

Other variables:
C:\Windows\system32\WindowsPowerShell\v1.0\Modules;
C:\Program Files (x86)\Microsoft SQL Server\120\Tools\PowerShell\Modules;
C:\Program Files (x86)\OfficeDevPnP (empty)

I also performed a deep search for that dll on my machine without finding other dll's...

@maerger
Copy link
Author

maerger commented Aug 11, 2015

Got it. There is still a reference in the latest version of ObjectListInstance.cs. Disabling this will make this part running well... Should there be a compiler directive to avoid this?

image

@erwinvanhunen
Copy link
Member

the properties are supported in On-Premises CSOM since the December 2014 CU: https://github.com/OfficeDev/PnP-Guidance/blob/master/articles/CSOM-Releases-And-New-Capabilities.md. We support with PnP the April 2015 CU and newer.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants