从 32 位应用程序使用 SPSite 访问 64 位 SharePoint [英] Using SPSite from 32bit application to access 64bit SharePoint

查看:35
本文介绍了从 32 位应用程序使用 SPSite 访问 64 位 SharePoint的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个以 32 位模式运行的批处理作业,因为它使用 32 位 COM 对象,这需要连接到 SharePoint 以更新列表.它在我的开发环境中工作,因为它是完整的 32 位.但在我的测试和生产环境中,我们使用 64 位 SharePoint,这是我从 SPSite 获得的:

I've created a batch job that running in 32bit mode as it using 32bit COM objectes, this need to connect to SharePoint to make updates to list. It works in my development environment as it is full 32bit. But in my test and prodution environment we use 64bit SharePoint and this is what I get from 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 位进程中失败的原因.

You simply need to run your batch job in a 64-bit process. The problem is that SharePoint has many COM objects under the hood which are compiled for 64-bit in your test and production environment. The SPSite and SPWeb objects actually wrap the COM objects which is why they fail in your 32-bit process.

一种解决方法是通过其 Web 服务而不是对象模型与 SharePoint 交互.

One work-around could be to interact with SharePoint through its Web Services instead of the object model.

这篇关于从 32 位应用程序使用 SPSite 访问 64 位 SharePoint的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆