Reputation: 45771
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
Upvotes: 0
Views: 15800
Reputation: 6371
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.
Upvotes: 0
Reputation: 454
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.
Microsoft.SharePoint.dll
Microsoft.SharePoint.Search.dll
Microsoft.SharePoint.Security.dll
microsoft.sharepoint.WorkflowActions.dll
OWSSVR.DLL
SHTML.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
Upvotes: 4
Reputation: 7341
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
In Solution Explorer, right-click the project, and then click Add Reference on the shortcut menu.
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.
Upvotes: 2
Reputation: 452
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
,
Upvotes: 1