Microsoft.SharePoint 和 Microsoft.Office 命名空间问题

发布于 2024-08-09 05:10:06 字数 5215 浏览 1 评论 0原文

我正在从以下教程学习开发基于 Microsoft Search Server 的应用程序,

http: //msdn.microsoft.com/en-us/library/ms497054.aspx

,它需要 Microsoft.SharePoint 和 Microsoft.Office 命名空间。谁能告诉我需要将哪些 SDK/DLL 添加到项目中才能使用命名空间?

我正在使用 VSTS 2008 + C# + .Net 开发 ASP.Net 应用程序。

EDIT1:我已经在另一台安装了 WSS 3.0 的计算机上进行了调试。我发现 Dll 位于 Program Files 下,但不在 Program Files (x86) 文件夹下。添加对 DLL 的引用并运行我的 aspx 页面后,我收到以下错误消息,您知道出了什么问题吗?

Server Error in '/' Application.
--------------------------------------------------------------------------------

Could not load file or assembly 'Microsoft.Office.Server.Search, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c' or one of its dependencies. An attempt was made to load a program with an incorrect format. 
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.BadImageFormatException: Could not load file or assembly 'Microsoft.Office.Server.Search, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c' or one of its dependencies. An attempt was made to load a program with an incorrect format.

Source Error: 

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.  

Stack Trace: 


[BadImageFormatException: Could not load file or assembly 'Microsoft.Office.Server.Search, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c' or one of its dependencies. An attempt was made to load a program with an incorrect format.]
   System.Reflection.Assembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection) +0
   System.Reflection.Assembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection) +43
   System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +127
   System.Reflection.Assembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +142
   System.Reflection.Assembly.Load(String assemblyString) +28
   System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +46

[ConfigurationErrorsException: Could not load file or assembly 'Microsoft.Office.Server.Search, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c' or one of its dependencies. An attempt was made to load a program with an incorrect format.]
   System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +613
   System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory() +203
   System.Web.Configuration.CompilationSection.LoadAssembly(AssemblyInfo ai) +105
   System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) +178
   System.Web.Compilation.WebDirectoryBatchCompiler..ctor(VirtualDirectory vdir) +163
   System.Web.Compilation.BuildManager.BatchCompileWebDirectoryInternal(VirtualDirectory vdir, Boolean ignoreErrors) +53
   System.Web.Compilation.BuildManager.BatchCompileWebDirectory(VirtualDirectory vdir, VirtualPath virtualDir, Boolean ignoreErrors) +175
   System.Web.Compilation.BuildManager.CompileWebFile(VirtualPath virtualPath) +83
   System.Web.Compilation.BuildManager.GetVPathBuildResultInternal(VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile) +261
   System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile) +101
   System.Web.Compilation.BuildManager.GetVirtualPathObjectFactory(VirtualPath virtualPath, HttpContext context, Boolean allowCrossApp, Boolean noAssert) +126
   System.Web.Compilation.BuildManager.CreateInstanceFromVirtualPath(VirtualPath virtualPath, Type requiredBaseType, HttpContext context, Boolean allowCrossApp, Boolean noAssert) +62
   System.Web.UI.PageHandlerFactory.GetHandlerHelper(HttpContext context, String requestType, VirtualPath virtualPath, String physicalPath) +33
   System.Web.UI.PageHandlerFactory.System.Web.IHttpHandlerFactory2.GetHandler(HttpContext context, String requestType, VirtualPath virtualPath, String physicalPath) +40
   System.Web.HttpApplication.MapHttpHandler(HttpContext context, String requestType, VirtualPath path, String pathTranslated, Boolean useAppConfig) +160
   System.Web.MapHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +93
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155

I am learning from the following tutorial to develop application based on Microsoft Search Server,

http://msdn.microsoft.com/en-us/library/ms497054.aspx

and it needs Microsoft.SharePoint and Microsoft.Office namespaces. Could anyone let me know which SDKs/DLLs are needed to be added to project in order to use the namespaces?

I am using VSTS 2008 + C# + .Net to develop an ASP.Net application.

EDIT1: I have debugged on another computer with WSS 3.0 installed. And I find the Dlls are under Program Files but not under Program Files (x86) folder. After adding the reference to the DLLs, and run my aspx page, I got the following error message, any ideas what is wrong?

Server Error in '/' Application.
--------------------------------------------------------------------------------

Could not load file or assembly 'Microsoft.Office.Server.Search, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c' or one of its dependencies. An attempt was made to load a program with an incorrect format. 
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.BadImageFormatException: Could not load file or assembly 'Microsoft.Office.Server.Search, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c' or one of its dependencies. An attempt was made to load a program with an incorrect format.

Source Error: 

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.  

Stack Trace: 


[BadImageFormatException: Could not load file or assembly 'Microsoft.Office.Server.Search, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c' or one of its dependencies. An attempt was made to load a program with an incorrect format.]
   System.Reflection.Assembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection) +0
   System.Reflection.Assembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection) +43
   System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +127
   System.Reflection.Assembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection) +142
   System.Reflection.Assembly.Load(String assemblyString) +28
   System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +46

[ConfigurationErrorsException: Could not load file or assembly 'Microsoft.Office.Server.Search, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c' or one of its dependencies. An attempt was made to load a program with an incorrect format.]
   System.Web.Configuration.CompilationSection.LoadAssemblyHelper(String assemblyName, Boolean starDirective) +613
   System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory() +203
   System.Web.Configuration.CompilationSection.LoadAssembly(AssemblyInfo ai) +105
   System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection compConfig) +178
   System.Web.Compilation.WebDirectoryBatchCompiler..ctor(VirtualDirectory vdir) +163
   System.Web.Compilation.BuildManager.BatchCompileWebDirectoryInternal(VirtualDirectory vdir, Boolean ignoreErrors) +53
   System.Web.Compilation.BuildManager.BatchCompileWebDirectory(VirtualDirectory vdir, VirtualPath virtualDir, Boolean ignoreErrors) +175
   System.Web.Compilation.BuildManager.CompileWebFile(VirtualPath virtualPath) +83
   System.Web.Compilation.BuildManager.GetVPathBuildResultInternal(VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile) +261
   System.Web.Compilation.BuildManager.GetVPathBuildResultWithNoAssert(HttpContext context, VirtualPath virtualPath, Boolean noBuild, Boolean allowCrossApp, Boolean allowBuildInPrecompile) +101
   System.Web.Compilation.BuildManager.GetVirtualPathObjectFactory(VirtualPath virtualPath, HttpContext context, Boolean allowCrossApp, Boolean noAssert) +126
   System.Web.Compilation.BuildManager.CreateInstanceFromVirtualPath(VirtualPath virtualPath, Type requiredBaseType, HttpContext context, Boolean allowCrossApp, Boolean noAssert) +62
   System.Web.UI.PageHandlerFactory.GetHandlerHelper(HttpContext context, String requestType, VirtualPath virtualPath, String physicalPath) +33
   System.Web.UI.PageHandlerFactory.System.Web.IHttpHandlerFactory2.GetHandler(HttpContext context, String requestType, VirtualPath virtualPath, String physicalPath) +40
   System.Web.HttpApplication.MapHttpHandler(HttpContext context, String requestType, VirtualPath path, String pathTranslated, Boolean useAppConfig) +160
   System.Web.MapHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +93
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

少年亿悲伤 2024-08-16 05:10:06

我认为您只安装了 WSS 而没有安装 MOSS。您需要在 WSS 之上安装 MOSS 才能获得您正在寻找的功能和程序集。

WSS DLL(如果这是您看到的全部内容,则说明您刚刚安装了 WSS)

Microsoft.SharePoint.dll

Microsoft.SharePoint.Search.dll

Microsoft.SharePoint.Security.dll

microsoft.sharepoint.WorkflowActions.dll

OWSSVR.DLL

SHTML.DLL

MOSS DLL (除了 WSS DLL 之外)

Microsoft.Office.Excel.Server.Udf.dll

Microsoft.Office.Excel.Server.WebServices.dll

Microsoft.Office.Policy.dll

Microsoft.Office.Server.dll

Microsoft.Office.Server.Search .dll

microsoft.office.workflow.tasks.dll

microsoft.sharepoint.portal.dll

Microsoft.SharePoint.Portal.SingleSignOn.dll

Microsoft.SharePoint.Portal.SingleSignOn.Security.dll

Microsoft.SharePoint.Publishing.dll

SSOCLI.DLL

I think you just have WSS installed and not MOSS. You need MOSS installed on top of WSS to get to the features and assemblies you are looking for.

WSS DLLs (If this is all you see you just have WSS installed)

Microsoft.SharePoint.dll

Microsoft.SharePoint.Search.dll

Microsoft.SharePoint.Security.dll

microsoft.sharepoint.WorkflowActions.dll

OWSSVR.DLL

SHTML.DLL

MOSS DLLs (In Addition to the WSS DLLs)

Microsoft.Office.Excel.Server.Udf.dll

Microsoft.Office.Excel.Server.WebServices.dll

Microsoft.Office.Policy.dll

Microsoft.Office.Server.dll

Microsoft.Office.Server.Search.dll

microsoft.office.workflow.tasks.dll

microsoft.sharepoint.portal.dll

Microsoft.SharePoint.Portal.SingleSignOn.dll

Microsoft.SharePoint.Portal.SingleSignOn.Security.dll

Microsoft.SharePoint.Publishing.dll

SSOCLI.DLL

看轻我的陪伴 2024-08-16 05:10:06

设置对 Microsoft.SharePoint 程序集的引用

创建项目后,添加
参考 Microsoft.SharePoint
程序集导入其名称空间和
实现 IntelliSense 功能
对象浏览器和代码编辑器。

添加对 Microsoft.SharePoint 程序集的引用

  1. 在“解决方案资源管理器”中,右键单击该项目,然后单击“添加”
    快捷菜单上的参考。

  2. 在“添加引用”对话框的“.NET”选项卡上,选择“Windows”
    列表中的 SharePoint Services
    组件,然后单击“确定”。

    要运行或调试使用 Microsoft.SharePoint 程序集的代码,您
    必须在服务器上运行代码
    运行 Windows SharePoint Services。
    如果您使用的是 Visual Studio 2005
    远程计算机,您无法运行或
    调试使用对象模型的代码。
    不过,您可以设置远程
    引用要写入的程序集
    代码并查看 Microsoft.SharePoint
    代码中代表的程序集
    编辑。添加远程引用
    这样,执行以下操作:

    单击“添加引用”对话框的“浏览”选项卡并导航至
    Microsoft.SharePoint.dll
    \Program Files\Common Files\Microsoft
    共享\Web服务器扩展\12\ISAPI
    运行 Windows 的服务器上的文件夹
    SharePoint 服务。你可以改为
    想要复制 Microsoft.SharePoint.dll
    从此文件夹到本地驱动器
    远程计算机,然后打开
    DLL 的本地副本。点击
    打开。

来源:MSDN

Setting a Reference to the Microsoft.SharePoint Assembly

After creating a project, add a
reference to the Microsoft.SharePoint
assembly to import its namespaces and
implement IntelliSense features in the
Object Browser and Code Editor.

To add a reference to the Microsoft.SharePoint assembly

  1. In Solution Explorer, right-click the project, and then click Add
    Reference on the shortcut menu.

  2. On the .NET tab of the Add Reference dialog box, select Windows
    SharePoint Services in the list of
    components, and then click OK.

    To run or debug code that uses the Microsoft.SharePoint assembly, you
    must run the code on the server
    running Windows SharePoint Services.
    If you are using Visual Studio 2005 on
    a remote computer, you cannot run or
    debug code that uses the object model.
    However, you can set a remote
    reference to the assembly to write
    code and see the Microsoft.SharePoint
    assembly represented in the Code
    Editor. To add a remote reference in
    this way, do the following:

    Click the Browse tab of the Add Reference dialog box and navigate to
    Microsoft.SharePoint.dll in the
    \Program Files\Common Files\Microsoft
    Shared\Web Server Extensions\12\ISAPI
    folder on the server running Windows
    SharePoint Services. You may instead
    want to copy Microsoft.SharePoint.dll
    from this folder to a local drive on
    the remote computer, and then open
    this local copy of the DLL. Click
    Open.

(Source: MSDN)

甜宝宝 2024-08-16 05:10:06

SharePoint 的主要 .dll 是 Microsoft.SharePoint.dllMicrosoft.Office.Server.dll,它们位于 %ProgramFiles%\Common Files\microsoft共享\Web服务器扩展\12\ISAPI

The main .dlls for SharePoint are Microsoft.SharePoint.dll and Microsoft.Office.Server.dll, which are located in %ProgramFiles%\Common Files\microsoft shared\Web Server Extensions\12\ISAPI,

蒲公英的约定 2024-08-16 05:10:06

只需将 microsoft.sharepoint.dll 放入 Web 应用程序的 bin 文件夹中即可。看看这篇文章:https ://sharepoint.stackexchange.com/questions/35502/how-to-add-reference-for-microsoft-sharepoint-to-a-web-application

另外,尝试在 C:\Program Files\Common 中查找dll 的 Files\Microsoft Shared\Web Server Extensions\14\ISAPI。这就是 Windows Server 2008 上的 Sharepoint 2010 的位置。我认为“12”配置单元适用于 Sharepoint 2007。如果您使用的是 Sharepoint 2010,那么它是 64 位,因此您将查看“程序文件”而不是“程序文件 (x86)”。

通过 bin 文件夹中的 dll,现在您可以在 .cs 代码隐藏文件中使用 using microsoft.sharepoint;

Just put the microsoft.sharepoint.dll in the bin folder of your web-application. Take a look at this post: https://sharepoint.stackexchange.com/questions/35502/how-to-add-reference-for-microsoft-sharepoint-to-a-web-application

Also, try looking in C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\14\ISAPI for the dll. That is where it is for Sharepoint 2010 on Windows Server 2008. I think the "12" hive is for Sharepoint 2007. If you are using Sharepoint 2010, then it is 64 bit, so you would look in "Program Files" and not "Program Files (x86)".

With the dll in your bin folder, now you can use using microsoft.sharepoint; in your .cs codebehind files.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文