SubPointSolutions / spmeta2

SharePoint artifact provision for .NET platform. Supports SharePoint Online, SharePoint 2019, 2016 and 2013 via CSOM/SSOM.
http://subpointsolutions.com/spmeta2
133 stars 56 forks source link

SP2016 CSOM - Field or property "DisplayName" does not exist. #1104

Open SubPointSupport opened 6 years ago

SubPointSupport commented 6 years ago

Brief description

SPMeta2 cannot pass "CanDeploy_ContentTypeFieldLink_WithProperties" test. If field link has got DiaplyName set, it would fail under SharePoint 2016 CSOM provision.

Somehow, GAC reference refers to CSOM assembly which has git fiel link "DisplayName" property. However, actual provision againt SharePoint 2016 farm (FP2) fails.

SPMeta2.Exceptions.SPMeta2ModelDeploymentException: There was an error while provisioning definition. Check ModelNode prop. ---> Microsoft.SharePoint.Client.ServerException: Field or property "DisplayName" does not exist. at Microsoft.SharePoint.Client.ClientRequest.ProcessResponseStream(Stream responseStream)

Rather unbelievable situation.

SharePoint API

SPMeta2 API

Any model with conten ttype field link with "DisplayName" set

var siteModel = SPMeta2Model.NewSiteModel(site =>
            {
                site.AddField(fieldOne);
                site.AddField(fieldTwo);

                site.AddContentType(contentType, c =>
                {
                    c.AddContentTypeFieldLink(new ContentTypeFieldLinkDefinition
                    {
                        FieldId = fieldOne.Id,
                        DisplayName = Rnd.String(),
                        Hidden = Rnd.Bool(),
                        Required = Rnd.Bool()
                    });

                    c.AddContentTypeFieldLink(new ContentTypeFieldLinkDefinition
                    {
                        DisplayName = Rnd.String(),
                        FieldId = fieldTwo.Id,
                        Hidden = Rnd.Bool(),
                        Required = Rnd.Bool()
                    });
                });
            });
digital88 commented 6 years ago

It is broken because FieldLink "Display Name" property was added for O365 in August 2016 (https://dev.office.com/blogs/new-sharepoint-csom-version-released-for-Office-365-august-2016-updated) and does not exists in Sharepoint 2016 API.

So it seems that your GAC dll are for O365 which are 99% equals to SP2016 dlls.

SubPointSupport commented 6 years ago

Indedd. But we are hitting this on VMs with SharePoint 2016 RTM upgraded to Feature Pack 2. Noticed while running regression tests, decided to track it separately.

For sure, the assembly is coming from GAC. Mayve VS2015 install brings this assmbly into GAC, not sure. We'll investigate a bit later.

This issues brings a broadr question on how SPMeta2 should be handling different API versions over CSOM. Looks that we should be checking remote server vesion instead of relying on the currently loaded C# assembly but this might be a rabbit hole in some sense.

digital88 commented 6 years ago

Maybe its because of Feature Pack 2. I dont have it installed, and my SP2016 dlls dont contain this property.

SubPointSupport commented 6 years ago

Could be. Either way this is highly undesired, tricky bahaviour for consumers. We should be handling it in a better way.

SubPointSupport commented 6 years ago

Indeed, a CSOM assembly in GAC might or might not cause this issue. Here are some notes:

Needs to be tested with the next infrastructure refresh, without VS2015 installed, and then with VS2017 only install. That needs to be done with VS2017 support (https://github.com/SubPointSolutions/metabox/issues/13) in https://github.com/SubPointSolutions/metabox - moving to the next milestone.

In a nutshell, this is not a critical issue but rather R&D to confirm what's going on. Normally, prod usage has the right assemblies along the app or in the GAC.

NZainchkovskiy commented 5 years ago

I have the same issue. I have Microsoft.SharePoint.Client 16.1.0.0 reference at my app (from nuget package Microsoft.SharePointOnline.CSOM) and 16.0.4588.1000 in GAC (FP2). So in SP2016 FP2 I can't set DisplayName property of content type field or it's some kind of bug? Thank you!