Microsoft.SharePoint 和 Microsoft.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
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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(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
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
(来源:MSDN)
(Source: MSDN)
SharePoint 的主要 .dll 是
Microsoft.SharePoint.dll
和Microsoft.Office.Server.dll
,它们位于%ProgramFiles%\Common Files\microsoft共享\Web服务器扩展\12\ISAPI
,The main .dlls for SharePoint are
Microsoft.SharePoint.dll
andMicrosoft.Office.Server.dll
, which are located in%ProgramFiles%\Common Files\microsoft shared\Web Server Extensions\12\ISAPI
,只需将 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.