我有这么简单的代码:
var entry = new DirectoryEntry("WinNT://DOMAIN/MachineName, Computer");
Console.WriteLine(entry.Guid);
Run Code Online (Sandbox Code Playgroud)
实际上,路径由命令行提供.编译这个简单的控制台应用程序用于测试,在我的测试中,我发现:
未处理的异常:System.IO.FileNotFoundException:找不到网络路径.
在System.DirectoryServices.Interop.UnsafeServices.DirectoryEntry.RefreshCache()的System.DirectoryServices.Interop.UnsafeNativeMethods.IAds.GetInfo()处于System.DirectoryServices.DirectoryEntry.FillCache(String propertyName)的System.DirectoryServices.DirectoryEntry.get_NativeGuid()处于System.DirectoryServices D:\ GetDirectoryEntryProperties\Program.cs中的GetDirectoryEntryProperties.Program.Main(String [] args)中的.DirectoryEntry.get_Guid():第15行
有任何想法吗?
我是所有机器的管理员,但我确实有另一个由Device Lock服务引起的问题导致了UnauthorizedAccessException审讯,但在这种情况下我甚至无法读取机器的Guid.
事件日志显示没有任何用处.
卢克
Bry*_*ach 13
我遇到了针对不同情况的相同错误消息.也许我找到的解决方案也可以帮到你.
升级到Windows 10后,我的计算机在启动时出现弹出错误,看起来就像您发布的那个错误.它是System.DirectoryServices.Interop.UnsafeNativeMethods.IAds.GetInfo()中的FileNotFoundException.
解决方案是将两个字符串从一个注册表位置复制到另一个位置.
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
Run Code Online (Sandbox Code Playgroud)