在WCF库中加载xml文档时出错

时间:2014-04-16 12:18:17

标签: c# xml wcf

我正在创建一个需要读取xml文件的wcf库,通过将在我的Windows 8应用程序中使用的服务传递元素。

问题是我首先使用相同的代码创建了一个WCF应用程序,它工作正常,但现在使用该库,xml文件返回为NULL。

  {

            var doc = XDocument.Load(System.Web.HttpContext.Current.Server.MapPath("/TestCodes.xml"));
            var testCodes = doc.Descendants("TextInfo");
            return testCodes.Select(item => 
            {
                var xElement = item.Element("Value");
                var element = item.Element("Description");
                if (element != null) 
                    return xElement != null ? new TestCodes()
                    {
                        Value = xElement.Value,
                        Description = element.Value
                    } : null;
                return null;
            }).ToList(); 
        }

是否有另一种方法可以读取与wcf应用程序不同的库中的xml文件?不幸的是,我必须使用WCF库,因此无法绕过该部分。

任何帮助都会很棒。

0 个答案:

没有答案