Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

System.Xml.Linq.XElement>' does not contain a definition for 'First' and no extension method 'First' accepting a first argument of [closed]

Tags:

linq

I am trying to change some custommessage encoder Using this blog

http://www.falconwebtech.com/post/2010/05/24/WCF-Interoperability-and-Extensibility-Part-Two.aspx

Here the author uses a extension method

 xmlMessage.Descendants(sec + "Security").First().Add(samlXml);

What namespace do I use for this .First This is the error I am getting

'System.Collections.Generic.IEnumerable' does not contain a definition for 'First' and no extension method 'First' accepting a first argument of type 'System.Collections.Generic.IEnumerable' could be found (are you missing a using directive or an assembly reference?)

I have the following namespaces included

using System;
using System.IO;
using System.Security.Cryptography;
using System.ServiceModel.Channels;
using System.Text;
using System.Xml;
using System.Xml.Linq;
using System.Reflection;
using System.Collections.Generic;
using System.Xml.XPath;
using System.Security.Cryptography.Xml;
using System.Security.Cryptography.X509Certificates;
using Microsoft.Web.Services3.Security;
using System.ServiceModel.Security;
using System.IdentityModel.Tokens;

I could've done my research but I am taking the easy way

Thank you

like image 233
user575219 Avatar asked Jun 29 '13 23:06

user575219


1 Answers

System.Linq is the one you're after.

http://msdn.microsoft.com/en-us/library/system.linq.enumerable.first.aspx

like image 133
Chris Avatar answered Oct 22 '22 10:10

Chris