I am trying to write a simple program that will connect to remote machines and request indexing status.
Here is the code that does this on my machine. This is working fine.
using System; using Microsoft.Search.Interop; namespace IndexStatus { class Program { static void Main(string[] args) { CSearchManager manager = new CSearchManager(); CSearchCatalogManager catalogManager = manager.GetCatalog("SystemIndex"); _CatalogPausedReason pReason; _CatalogStatus pStatus; Console.WriteLine(catalogManager.NumberOfItems().ToString()); int plIncrementalCount; int plNotificationQueue; int plHighPriorityQueue; catalogManager.NumberOfItemsToIndex(out plIncrementalCount, out plNotificationQueue, out plHighPriorityQueue); Console.WriteLine(plIncrementalCount.ToString()); Console.WriteLine(plNotificationQueue.ToString()); Console.WriteLine(plHighPriorityQueue.ToString()); catalogManager.GetCatalogStatus(out pStatus, out pReason); Console.WriteLine(pStatus.ToString() + " " + pReason.ToString()); Console.ReadLine(); } } }
However, when I call GetCatalog on "mycomputername.SystemIndex" instead of "SystemIndex" , I get
An unhandled exception of type "System.Runtime.InteropServices.COMException" occurred in IndexStatus.exe
Additional information: Exception from HRESULT: 0x80042103

Visual Studio 2015 works as an administrator in Windows 8.1. The target computers will be mainly Windows 7 systems, and basically the program will start from Windows 10. I use Microsoft.Search.Interop.dll from the Microsoft Windows Search 3.X SDK, downloaded from here . I turned off the firewall in case it had anything to do with it, but apparently it didn't.
I checked that I get the same exception if I call the function to complete nonsense, for example "sdfd" . And I found this :
MSS_E_CATALOGNOTFOUND - 0x80042103 - (8451) WindowsSearchErrors.h
The specified catalog was not found. Check to see if it was deleted, or if there are errors in your application code.
I tried using "localhost" instead of the machine name, but that did not help.
MSDN docs say the following:
Currently, Microsoft Windows Desktop Search (WDS) 3.0 only supports one directory, and it is called SystemIndex.
I am not sure how to understand this. Perhaps the method cannot choose between different machines? If so, is there a way to connect to the remote directory and make these requests other than using something like PsExec?
Re Ben N answers: It starts to become deep water for me, but I'm more fascinated than afraid. :) Your code worked for me after several modifications:
CSearchManagerClass manager = System.Runtime.InteropServices.Marshal.CreateWrapperOfType(comManager, typeof(CSearchManagerClass)); will not compile in Visual Studio 2015 and will give the following errors:

The second error is easy to fix by simply adding a cast:
CSearchManagerClass manager = (CSearchManagerClass)System.Runtime.InteropServices.Marshal.CreateWrapperOfType(comManager, typeof(CSearchManagerClass));
Regarding the error message “Interaction type cannot be implemented”, I found this question . There are two suggested solutions:
The first solution is to compile the program, but this affects portability. Now the program will not run on a computer that does not have a .dll. The second solution compiles, but throws
An unhandled exception of type "System.ArgumentException" occurred in mscorlib.dll
Additional Information: The type must be __ComObject or be obtained from __ComObject.
on this exact line when I run it on my machine.
But there is one more problem, and I have no idea about this. When I run it on my colleague's computer (I am an administrator on my computer, and Visual Studio works with administrator rights), I get
An unhandled exception of type "System.UnauthorizedAccessException" occurred in mscorlib.dll
Additional information: retrieving a COM class factory for a remote component with CLSID {7D096C5F-AC08-4F1F-BEB7-5C22C517CE39} from the machine computer name failed due to the following error: 80070005 computer name.
This scares me a bit because I know almost nothing about COM. I checked that DCOM is enabled on his computer and on mine. But when I try to go to his computer in component services, it displays as
and DCOM Config is not in the tree. The same thing happens for other computers in the domain (although I have administrator rights on all workstations). This blog suggests that this may be a firewall problem, and if so, this is not something that will be possible to overcome.
Both of your answers are certainly worthy of a worthy already, but if you have any suggestions or you can shed light on what is happening, I would be very grateful. If I can't get it to work, everything is fine, but I definitely would like to extract as much knowledge as possible from this.