我创建了一个在 32 位模式下运行的批处理作业,因为它使用 32 位 COM 对象,这需要连接到 SharePoint 才能更新列表。
它可以在我的开发环境中运行,因为它是完整的 32 位。但在我的测试和生产环境中,我们使用 64 位 SharePoint,这是我从 SPSite 获得的结果:
System.IO.FileNotFoundException:
The Web application at http://<my sp host>/ could not be found.
Verify that you have typed the URL correctly.
If the URL should be serving existing content, the system administrator may need to add a new request URL mapping to the intended application.
at Microsoft.SharePoint.SPSite..ctor(SPFarm farm, Uri req...
这就是我所做的
using (SPSite site = new SPSite(_url))
{
using (SPWeb web = site.OpenWeb())
{
try
{
SPList list = web.Lists[new Guid(_listID)];
SPListItem item = list.GetItemById(id);
item[field] = value;
item.SystemUpdate(false);
}
catch (Exception x)
{
log.Error(x);
}
}
}
您只需在 64 位进程中运行批处理作业即可。问题是 SharePoint 背后有许多 COM 对象,它们在测试和生产环境中编译为 64 位。 SPSite 和 SPWeb 对象实际上包装了 COM 对象,这就是它们在 32 位进程中失败的原因。
一种解决方法是通过 SharePoint 的 Web 服务而不是对象模型与 SharePoint 进行交互。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)