鉴于从RssToolkit下面的代码在RssXmlHelper.cs:XmlSerializer.Serialize需要很长时间...为什么?
/// <summary>
/// Returns XML of the Generic Type.
/// </summary>
/// <param name="rssDocument">The RSS document.</param>
/// <typeparam name="T">RssDocumentBase</typeparam>
/// <returns>string</returns>
public static string ToRssXml<T>(T rssDocument) where T : RssDocumentBase
{
if (rssDocument == null)
{
throw new ArgumentNullException("rssDocument");
}
using (StringWriter output = new StringWriter(new StringBuilder(), CultureInfo.InvariantCulture))
{
XmlSerializer serializer = new XmlSerializer(typeof(T));
serializer.Serialize(output, rssDocument);
return output.ToString();
}
}
当serializer.Serialize()被调用我的WCF服务,它需要一大堆的时间。
我有这个坐在我从我的项目调用的WCF服务。我进入它,果然,这是问题点。
然后我在我的解决方案中引用该项目,并没有问题。
在WCF服务中使用它时,我应该做些什么不同吗?
- 更新 -
好了,所以我安装微软的Windows SDK的Windows 7和.NET Framework 4,跑sgne.exe RssToolkit.dll并得到以下错误:
Error: An attempt was made to load an assembly with in incorrect format [path to rsstoolkit.dll]
- Could not load file or assemply [path to rsstoolkit.dll] or one of its dependencies. This assembly was build by a runtime newer than the currently loaded runtime and cannot be loaded.
我的RssToolkit项目的目标框架设置为4.0,与Windows SDK for .Net 4匹配。这是不正确的?
标题有点误导:WCF与缓慢的“XmlSerializer”问题无关,所以我编辑了它。 –