views:

2300

answers:

3

Hello everyone,

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

thanks in advance, George

+1  A: 

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,

Hirvox
I only find Microsoft.SharePoint.Server.xml there, no Microsoft.Office.Server.dll. Any ideas what is wrong?
George2
Do I need to install some SDK in order to use the Dlls?
George2
+1  A: 

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)

Moayad Mardini
Hi Moayad, under \Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\ISAPI, I only find Microsoft.SharePoint.xml, no Microsoft.SharePoint.dll. Any ideas what is wrong?
George2
Do I need to install some SDK in order to use the Dlls?
George2
Sure, you should install Windows SharePoint Services SDK.
Moayad Mardini
George2
You need to get the dlls from a server with SharePoint installedIn fact it's highly recommended to develop using a Server OS with SharePoint installed (can be virtual machine). This will change for SP2010 where Vista/Win7 are supported development environments
Per Jakobsen
Thanks Per, I have found the DLLs following your comments. But when running my aspx web page with QueryEx web service calls, I got some exceptions. I posted the error message in EDIT1 section of my original post. Any ideas what is wrong?
George2
+2  A: 

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

Junx