CeccoCQ
CeccoCQ

Reputation: 3754

C# Microsoft.Search.Interop cannot be found

I've developed a software that uses microsoft.search.interop.dll as referenced libraries. When I compile with a debug mode, my app works correctly, but when I try to compile in release mode, I get this error:

Microsoft.Search.Interop cannot be found.

I've downloaded code sample from http://archive.msdn.microsoft.com/windowssearch (DSearch project).

How can I solve my problem?

Solution found (run the following on one line):

set MSSdk=c:\Program Files\Microsoft SDKs\Windows\v7.1 
"%MSSdk%\Bin\tlbimp.exe" "%MSSdk%\Lib\SearchAPI.tlb" /namespace:Microsoft.Search.Interop /out:Microsoft.Search.Interop.dll /silent

Upvotes: 3

Views: 4038

Answers (3)

djabraham
djabraham

Reputation: 776

I have been seeing this a lot, so I thought I might clarify something..

Those commands belong in the pre-build steps of a project that references the Microsoft.Search.Interop assembly. Ideally, that dll would be generated in the project bin folder, by adding the following to the "Pre-build event command line" in the "Build Events" section:

set MSSdk=c:\Program Files\Microsoft SDKs\Windows\v7.1

"%MSSdk%\Bin\tlbimp.exe" "%MSSdk%\Lib\SearchAPI.tlb" /namespace:Microsoft.Search.Interop /out:Microsoft.Search.Interop.dll /silent

Note: You would not want to use the /silent switch on the command line and the path will differ on 64 bit machines or depending on the version of the SDK you have, so mine was as follows:

C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A

Upvotes: 0

CSCProgrammer
CSCProgrammer

Reputation: 41

I used the author's proposed solution and it worked for me in Visual Studio 2012 on the DSearch.zip MSDN example. To implement the solution, after I imported the project, I went to Project -> {project-name} properties. From there, go to build events. Syntax for the author's proposed code did not work initially for me, but changing as follows did:

set MSSdk="c:\Program Files\Microsoft SDKs\Windows\v7.1"
%MSSdk%\Bin\tlbimp.exe %MSSdk%\Lib\SearchAPI.tlb /namespace:Microsoft.Search.Interop /out:Microsoft.Search.Interop.dll /silent

You can confirm this works by running the command in your windows cmd prompt also. (read:"run cmd as administrator"; no message response==it worked)

The solution is also voted on/accepted at social.MSDN.microsoft.com

Upvotes: 4

Somnath
Somnath

Reputation: 3277

It's may be that the dll is not present or its may be caching issue with Visual Studio. Please try the steps below. It works for me.

  1. Download Windows Search 3.x SDK from this Link and extract it.
  2. You will find the microsoft.search.interop.dll inside folder name Managed.
  3. Remove the existing reference of microsoft.search.interop.dll from your project.
  4. Then Clean the solution.
  5. Close your project and close Visual Studio.
  6. Reopen the project and add a new reference to the microsoft.search.interop.dll present inside folder name Managed.
  7. Now compile your project
  8. Now run the following command

    set MSSdk=c:\Program Files\Microsoft SDKs\Windows\v7.1 "%MSSdk%\Bin\tlbimp.exe" "%MSSdk%\Lib\SearchAPI.tlb" /namespace:Microsoft.Search.Interop /out:Microsoft.Search.Interop.dll /silen

Upvotes: 0

Related Questions