none
Rookie: How to declare Microsoft.VisualBasic.Devices Namespace in Visual Studio RRS feed

  • Frage

  • Hi there,

    I'm new to Visual Studio. I want to code an Windows app in VB.NET for me to run on my students computer while they are doing a classroom test, sothat they can't use their WiFi-network for cheating.

    Now I found the option to use My.Computer which might not be the most elegant way to code (as I red somewhere), but seem to be a very easy way to what network activities, play WAV-warnings and so on.

    On Visual Studio 2019 Community I just opened an Windows-Console-App for VB.NET and tried to use My.Computer... When compiling there is an error-message saying that computer "is noch declared".

    OK, so I found that the namespace Microsoft.VisualBasic.Devices is required for using it.

    I almost used the Imports-command at the very beginning of my code ....

    Imports System
    Imports System.Net.NetworkInformation

    All worked fine so that VS is completing / showing possible ways to complete the information after the dot, but when trying to go to the Microsoft.VisualBasic.  the   Devices option is not shown.

    Imports Microsoft.VisualBasic.  (without any auto-fill option :-()

    Now is the questionis if I have to include something (a path or a dll or whatever) so that the namespace is included???

    I think that this will be only a small step for menkind but a big step for me ;-)

    Thanks in advance

    Joe

    Samstag, 16. Januar 2021 14:18

Antworten

Alle Antworten

  • Hi,

    die Klassen im Microsoft.VisualBasic.Devices Namespace befinden sich in der Microsoft.VisualBasic.Forms.dll. Diese musst Du daher als Verweis in dein Projekt mit aufnehmen.

    Siehe dazu u.a.

      Microsoft.VisualBasic.Devices Namespace

    Ich würde aher eher auf My.... und Microsoft.VisualBasic... verzichten und die normalen .NET Klassen dafür verwenden. Je nach genauer Anforderung muss man da allerdings schon etwas suchen, bis man passende Äquivalente gefunden hat :)


    Gruß, Stefan
    Microsoft MVP - Visual Developer ASP/ASP.NET (2001-2018)
    https://www.asp-solutions.de/ - IT Beratung, Softwareentwicklung, Remotesupport

    Samstag, 16. Januar 2021 15:28
    Moderator
  • Hallo Stefan,

    vielen Dank für Deine prompte Antwort. Nun stellt sich mir natürlich die Frage, wie ich den Verweis in mein Projekt aufnehme.... Wie ich ja schon geschrieben habe, bin ich neu bei VS und habe daher nicht so richtig den Plan, wo ich das angeben muss.

    Neben der Tatsache, dass ich nicht weiß, wo ich das in VS eintragen sollte habe ich auch die Datei auf meiner gesamten Festplatte leider nicht gefunden.

    Für eine erneute Hilfestellung wäre ich Dir sehr dankar.

    Gruß

    Joe

    Samstag, 16. Januar 2021 19:03