Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

FileNotFoundException at System.DirectoryServices.Interop.UnsafeNativeMethods.IAds.GetInfo()

Tags:

c#

.net

I have this simple line of code:

var entry = new DirectoryEntry("WinNT://DOMAIN/MachineName, Computer");
Console.WriteLine(entry.Guid);

In reality, the path is supplied by command line. This simple Console App is compiled for testing and in my tests I find that:

  • Connecting to my own Windows 7 PC works.
  • Connecting to any other Windows XP machine on the network, works.
  • Connecting to any other Windows 7 machines on the network fails with:

Unhandled Exception: System.IO.FileNotFoundException: The network path was not found.

at System.DirectoryServices.Interop.UnsafeNativeMethods.IAds.GetInfo() at System.DirectoryServices.DirectoryEntry.RefreshCache() at System.DirectoryServices.DirectoryEntry.FillCache(String propertyName) at System.DirectoryServices.DirectoryEntry.get_NativeGuid() at System.DirectoryServices.DirectoryEntry.get_Guid() at GetDirectoryEntryProperties.Program.Main(String[] args) in D:\GetDirectoryEntryProperties\Program.cs:line 15

Any ideas?

I am an administrator on all machines, however I did have another issue caused by a Device Lock service which caused an UnauthorizedAccessException on interrogation, but in this case I can't even read the Guid of the machine.

Event Log is showing nothing of use.

Luke

like image 563
Luke Puplett Avatar asked Aug 24 '12 17:08

Luke Puplett


1 Answers

I came across the same error message for a different situation. Perhaps the solution I found could help you too.

After upgrading to Windows 10, my computer gave a popup error when booting up that looked just like the one you posted. It was a FileNotFoundException at System.DirectoryServices.Interop.UnsafeNativeMethods.IAds.GetInfo().

The solution was to copy two strings from one registry location to another.

Copy these strings: RegisteredOwner and RegisteredOrganization

From: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion

To: HKEY_LOCAL_MACHINE\SOFTWARE\WOW6432Node\Microsoft\Windows NT\CurrentVersion
like image 146
Bryan Roach Avatar answered Oct 23 '22 11:10

Bryan Roach