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

时间:2009-10-27 07:34:31

标签: c# .net sharepoint visual-studio-2008 ms-office

我正在学习以下教程,以开发基于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

4 个答案:

答案 0 :(得分:4)

我认为你只安装了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

答案 1 :(得分:2)

  

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

     

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

     

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

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

  2.   
  3. 在“添加引用”对话框的“.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 Services。你可以改为   想复制Microsoft.SharePoint.dll   从此文件夹到上的本地驱动器   远程计算机,然后打开    DLL的本地副本。点击   打开。

  4.   

Source: MSDN

答案 2 :(得分:1)

SharePoint的主要.dll是Microsoft.SharePoint.dllMicrosoft.Office.Server.dll,它们位于%ProgramFiles%\Common Files\microsoft shared\Web Server Extensions\12\ISAPI

答案 3 :(得分:0)

将microsoft.sharepoint.dll放在网络应用程序的bin文件夹中。看一下这篇文章:https://sharepoint.stackexchange.com/questions/35502/how-to-add-reference-for-microsoft-sharepoint-to-a-web-application

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

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