Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/visual-studio-2010/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
从32位应用程序使用SPSite访问64位SharePoint_Sharepoint - Fatal编程技术网

从32位应用程序使用SPSite访问64位SharePoint

从32位应用程序使用SPSite访问64位SharePoint,sharepoint,Sharepoint,我已经创建了一个批处理作业,它在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

我已经创建了一个批处理作业,它在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...

我不认为这是一个32/64位的问题,因为我在32位上开发并部署到64位的情况是一样的。(实际上,我们正在运行32位和64位WFE)


由于该异常是从SPSite构造函数引发的,因此我将进一步调查运行代码的机器(SP框)是否真正识别该URL。

您只需在64位进程中运行批处理作业。问题是SharePoint有许多COM对象,这些对象在测试和生产环境中编译为64位。SPSite和SPWeb对象实际上包装了COM对象,这就是为什么它们在32位进程中失败的原因


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

如果我将应用程序编译为64位,并尝试使用SPSite代码,那么一切都会很好。因此,它与64位SharePoint不允许32位调用有关。我可以使用webservice进行列表更新,但它总是创建listitem的新版本,并且我需要该项具有相同的版本。我需要它在32位模式下运行,就像我使用其他仅在32位模式下工作的COM对象一样。这不是一个选项。使用SharePoint webservice不起作用,因为我需要执行系统更新,因此该项不会获得新版本。我想我们在这里遇到了一个难题,因为托管SharePoint API下的64位SharePoint COM对象在32位模式下根本无法工作。这是更多的工作,但您可以考虑安装自己的Web服务,支持对列表项的SytUp更新。如果您真的需要使用对象模型而不是Web服务,那么选择生成一个64位的进程来进行该交互,并将调用代理回您的32位主进程。使用WCF双工契约快速地来回推送信息。我的修复方法是为我的32位COM对象制作一个webservice包装器,并让我的批处理作业B运行64位。
        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);
                }
            }
        }