0

I try to run the following command:

 Console.WriteLine(My.Computer.Name)

I faced the following error:

"Computer" is not a member of "programName.My"

I am sincerely asking to know how I can overcome this error

djv
  • 15,168
  • 7
  • 48
  • 72
  • 5
    Looks like you defined your own identifier named "My". – Hans Passant Nov 25 '19 at 14:55
  • 2
    I believe your question was answered here: https://stackoverflow.com/questions/13388164/get-the-computer-name – B. Seberle Nov 25 '19 at 14:58
  • No, actually I want to access all features of "My." like "My.Computer", "My. Application", "My.Settings" and so on. – amirhossein Nov 25 '19 at 15:06
  • 1
    As Hans says, looks like you made your own namespace called My (via `programName.My`) and your code is trying to read `Computer` from that namespace instead of the Microsoft-defined one. You need to tell the code exactly which namespace to look in – ADyson Nov 25 '19 at 15:08
  • `Console.WriteLine(New Devices.ServerComputer().Name)`... As already mentioned you must have defined something already named `My` and it's conflicting with the framework namespace already. – Trevor Nov 25 '19 at 15:23
  • 3
    You probably selected a .Net Core template to create the project. The _My Namespace_ is a work in progress on the Core framework with minimal features currently supported. See [Visual Basic in .NET Core 3.0](https://devblogs.microsoft.com/vbteam/visual-basic-in-net-core-3-0/) for some info. – TnTinMn Nov 25 '19 at 15:53

1 Answers1

2

you can just use without function:

System.Net.Dns.GetHostName

or:

Environment.MachineName

  • Thanks, it perfectly works for the computer's name. how can I get to other related information like clipboard and so on? These functions were available in the previous version of VB .NET under "My.Computer.Name" or "My.Computer.Info" and so on. – amirhossein Nov 26 '19 at 09:19