1

Setup

  • 2 lists, linked by a lookup in one of the lists
  • CamlQuery to get items together with fields from other list (projectedfields)

Problem

When I retreive the listitems with the CAMLQuery, it works. All correct listitems are returned. But when I try to convert the ProjectedFields, it fails and throws an error (see below)

Error

The type 'Microsoft.SharePoint.Client.FieldLookupValue' exists in both 'Microsoft.SharePoint.Client.dll' and 'Microsoft.SharePoint.Client.dll'

Code

var foo = (FieldLookupValue)listItem["bar"]

Type

When I'm in debugmode and try to get the type of the field (immediate window):

listItem["bar"].GetType()

{Name = "FieldLookupValue" FullName = "Microsoft.SharePoint.Client.FieldLookupValue"} [System.RuntimeType]: {Name = "FieldLookupValue" FullName = "Microsoft.SharePoint.Client.FieldLookupValue"} base: {Name = "FieldLookupValue" FullName = "Microsoft.SharePoint.Client.FieldLookupValue"} Assembly: {Microsoft.SharePoint.Client, Version=16.1.3912.1204, Culture=neutral, PublicKeyToken=71e9bce111e9429c} AssemblyQualifiedName: "Microsoft.SharePoint.Client.FieldLookupValue, Microsoft.SharePoint.Client, Version=16.1.3912.1204, Culture=neutral, PublicKeyToken=71e9bce111e9429c" Attributes: Public | BeforeFieldInit BaseType: {Name = "ClientValueObject" FullName = "Microsoft.SharePoint.Client.ClientValueObject"} ContainsGenericParameters: false DeclaringMethod: 'listItem["bar"].GetType().DeclaringMethod' threw an exception of type 'System.InvalidOperationException' DeclaringType: null FullName: "Microsoft.SharePoint.Client.FieldLookupValue" GenericParameterAttributes: 'listItem["bar"].GetType().GenericParameterAttributes' threw an exception of type 'System.InvalidOperationException' GenericParameterPosition: 'listItem["bar"].GetType().GenericParameterPosition' threw an exception of type 'System.InvalidOperationException' GenericTypeArguments: {System.Type[0]} GUID: {601ca347-ae93-3db5-ac96-5aa71e30632f} HasElementType: false IsAbstract: false IsAnsiClass: true IsArray: false IsAutoClass: false IsAutoLayout: true IsByRef: false IsClass: true IsCOMObject: false IsConstructedGenericType: false IsContextful: false IsEnum: false IsExplicitLayout: false IsGenericParameter: false IsGenericType: false IsGenericTypeDefinition: false IsImport: false IsInterface: false IsLayoutSequential: false IsMarshalByRef: false IsNested: false IsNestedAssembly: false IsNestedFamANDAssem: false IsNestedFamily: false IsNestedFamORAssem: false IsNestedPrivate: false IsNestedPublic: false IsNotPublic: false IsPointer: false IsPrimitive: false IsPublic: true IsSealed: false IsSecurityCritical: false IsSecuritySafeCritical: false IsSecurityTransparent: true IsSerializable: false IsSpecialName: false IsUnicodeClass: false IsValueType: false IsVisible: true MemberType: TypeInfo Module: {Microsoft.SharePoint.Client.dll} Namespace: "Microsoft.SharePoint.Client" ReflectedType: null StructLayoutAttribute: {System.Runtime.InteropServices.StructLayoutAttribute} TypeHandle: {System.RuntimeTypeHandle} TypeInitializer: null UnderlyingSystemType: {Name = "FieldLookupValue" FullName = "Microsoft.SharePoint.Client.FieldLookupValue"}

1 Answer 1

-1

Try

FieldUserValue fuv = (FieldUserValue)item["FIELD_NAME"];
fuv.LookupValue.ToString()

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.