Возможно ли, что среда. Machinename возвращает строку нулевой длины

StackOverflow https://stackoverflow.com/questions/6042976

Вопрос

Я преследую странную ошибку на сайте клиента и задавался вопросом, возможно, что Environment.MachineName может вернуть строку нулевой длины.Документы говорят, что это читается из реестра, но не указывает где.Я не могу представить, что машина не может иметь имя NetBIOS, но просто хотел спросить.

Редактировать

После некоторого расследования, кажется, что это не возвращало нулевую длину строки, но мне просто интересно, если это возможно.

Это было полезно?

Решение

I don't know if it can be an empty string, sorry, but concerning the registry you might want to check the following (and subkeys):

HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\ComputerName\ActiveComputerName
HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\ComputerName\ComputerName

On my system it is actually looking at HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\ComputerName\ActiveComputerName\ComputerName:

enter image description here

BTW, as you can see I tried to figure this out using SysInternals Process Monitor, but initially failed. Then i figured, that the above keys (and some related ones) are suppressed by default. Just in case you try the same be aware of that.

You might also check the value of the %COMPUTERNAME%. Although I have no reference or direct evidence, I would assume that it gets its value from the same source.

I know this is not a real answer to your question, but it wouldn't fit in a comment either.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top