private SmtpClient getServer()
{
return (from e in doc.Elements("emailsetting")
select new SmtpClient()
{
Host = e.Attribute("server").Value,
Port = Convert.ToInt32(e.Attribute("port").Value)
}).FirstOrDefault();
}
XML配置文件:为什么这个LINQ抛出NullReferenceException?
<emailsetting>
<stmp server="10.182.182.182" port="25" />
<from address="[email protected]"/>
<to address=""/>
<cc address=""/>
</emailsetting>
为什么抛出异常: 的NullReferenceException是未处理不设置到对象的实例 对象引用。
我是新来的LINQ,PLZ的帮助。
'SMTP' 拼写为XML 'STMP'。 :) – 2012-07-16 09:55:45