SharePoint API:2003 年与 2007 年
我编写了一个使用 2007 API 来遍历 SharePoint 对象模型的解决方案。 现在我也需要支持 SP 2003。 做这个的最好方式是什么?
是否可以/建议使用 2007 api 来访问 2003 SharePoint 场?
如果我使用 2007 API,我是否必须使用已弃用的类来(例如)引用配置数据库,还是使用 2007 类(例如 SPFarm)?
或者我是否对 SP 2007 使用 2007 API,对 SP 2003 使用 2003 API...? 问题是两者都使用相同的命名空间和类名。 所以它可能会变得混乱。 (除非我使用别名来引用不同的命名空间?)
I have coded a solution that uses the 2007 API to traverse the SharePoint object model. Now I need to support SP 2003 as well. What is the best way to do this?
Is it possible / recommended to use the 2007 api to get access to a 2003 SharePoint Farm?
If I use the 2007 API, do I have to use the deprecated classes to (for instance) reference a configuration database, or do I use the 2007 classes, such as SPFarm?
Or do I use the 2007 API for SP 2007 and the 2003 API for SP 2003...? Problem with this is that both use the same namespaces and class names. So it can get messy. (Except maybe if I use aliases to reference the different namespaces?)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
据我所知,2007 API 和 2003 API 不兼容。 那么是吗? 您将需要同时实现两者。
我可以建议使用接口 ISharePointAPI 和两个实现 SharePoint2007API 和 SharePoint2003API。 该实现甚至可以打包到不同的程序集中,因此您不会遇到引用地狱:)。 这也将保护您免受 2010 API 更改的影响,因为您需要的是实施 SharePoint2010API...
As far I know the 2007 API and the 2003 API are incompatible. So yes? you will need to implement both.
I can suggest to have interface ISharePointAPI and two implementations SharePoint2007API and SharePoint2003API. This implementations can even be packaged to different assemblies, so you will not have reference hell :). This is will also protect you from 2010 API changes as what you will need is to implement SharePoint2010API...
这些接口(大部分)在命名空间/类/成员用法中兼容,但您必须为正确版本的 SharePoint 使用正确版本的 API。 您还必须考虑到WSS2/SPS2003 默认使用.NET1.1。
我的解决方案是使用 MSBEE 和一些 MSBUILD 忍者移动到从源代码中吐出两个版本。
第一个目标为 .NET2 并引用 Microsoft.SharePoint.dll v12 (WSS3/MOSS2007),第二个目标为 .NET1.1 并引用 Microsft.Sharepoint.dll v11 (WSS2/SPS2003)。
设置起来非常方便,但设置后效果很好。 如果确实存在代码差异,则可以使用条件编译:-
这篇文章< /a> 提供了更多细节。 这是一个很大的话题,我一直想写一篇博客文章来提供一些技巧。
The interfaces are (mostly) compatible in a namespace/class/member USAGE but you have to use the right version of the API for the correct version of SharePoint. You also have to consider that by WSS2/SPS2003 uses .NET1.1 by default.
My solution to this is to use MSBEE and some MSBUILD ninja moves to spit out two versions from your source code.
The first targets .NET2 and references Microsoft.SharePoint.dll v12 (WSS3/MOSS2007) and the second targets .NET1.1 and references Microsft.Sharepoint.dll v11 (WSS2/SPS2003).
Its quite a faf to setup but works very well after that. Where you do have code differences you can use conditional compilation :-
This article gives a little more detail. Its a big topic and I've been meaning to write a blog post with some tip.