VisualBasic und Mono - Fehler bei der Ausführung

  • VB.NET

Es gibt 13 Antworten in diesem Thema. Der letzte Beitrag () ist von meyer0815.

    VisualBasic und Mono - Fehler bei der Ausführung

    Hallo alle zusammen,
    ich habe mir vor einiger zeit eine Raspberry Pi mit einem 8-fach relay Modul und möchte nun mit mit vb.net die relais über TCP/IP ansteuern.

    Also ich habe jetzt eine Konsolenanwendung erstellt , mit der ich erst einmal via SSA am Raspberry selbst die Relays steuern kann.
    :)
    Soweit , so gut !


    Wenn ich jetzt aber die consoleRelay.exe (das Programm) mit mono starten möchte kommt folgende Fehlermeldung :

    Quellcode

    1. mono '/home/nas/consoleRelay.exe' file_to_compile.4th Missing method SetProjectError in assembly /home/nas/consoleRelay.exe, type Microsoft.VisualBasic.CompilerServices.ProjectData
    2. Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.VisualBasic, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies.File name: 'Microsoft.VisualBasic, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'[ERROR] FATAL UNHANDLED EXCEPTION: System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.VisualBasic, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies.File name: 'Microsoft.VisualBasic, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'

    ?( ?( ?(

    Daraufhin habe ich nochmal gegoogelt und herausgefunden das vb.net von MONO nicht unterstützt sei.
    Stimmt das ?

    Müsste ich tatsächlich auf C# umsteigen und selbst wenn , könnten C# (raspberry) und vb.net ( Steuer PC ) miteinander über TCP/IP komunizieren ? ;(

    würde mich freue wenn mir jemand helfen kann ;) :)
    Also VB.NET läuft definitv unter Mono auf dem Raspberry. Du hast scheinbar nicht alle notwendigen Libs installiert - wenn ich es richtig im Kopf habe braucht man für VB noch zusätzliches Zeug, versuche mal:

    sudo apt-get install mono-vbnc
    danke für die schnelle Antwort
    ich versuche es gerade einmal
    :)

    /edit :
    Es geht !
    Jetzt aber tritt noch ein Fehler auf , wenn sich auf /sys/class/gpio/ zugreifen möchte ...

    Quellcode

    1. Unhandled Exception: System.UnauthorizedAccessException: Access to the path "/sys/class/gpio/gpiochip0/subsystem/gpiochip0/subsystem/gpiochip0/subsystem/gpiochip0/subsystem/gpiochip0/subsystem/gpiochip0/subsystem/gpiochip0/subsystem/gpiochip0/subsystem/gpiochip0/subsystem/gpiochip0/subsystem/gpiochip0/subsystem/gpiochip0/subsystem/gpiochip0/subsystem/gpiochip0/subsystem/gpiochip0/subsystem/gpiochip0/subsystem/gpiochip0/subsystem/gpiochip0/subsystem/gpiochip0/subsystem/gpiochip0/subsystem/unexport" is denied.
    2. at System.IO.File.Delete (System.String path) [0x00000] in <filename unknown>:0
    3. at Microsoft.VisualBasic.FileIO.FileSystemOperation.DeleteItem (Microsoft.VisualBasic.FileIO.Info Info, Int32 Counter, Boolean DoUpdate) [0x00000] in <filename unknown>:0
    4. at Microsoft.VisualBasic.FileIO.FileSystemOperation.Delete () [0x00000] in <filename unknown>:0
    5. at Microsoft.VisualBasic.FileIO.FileSystemOperation.ExecuteDirDelete () [0x00000] in <filename unknown>:0
    6. at Microsoft.VisualBasic.FileIO.FileSystem.DeleteDirectory (System.String directory, UIOption showUIOption, RecycleOption recycle, UICancelOption onUserCancel, DeleteDirectoryOption onDirectoryNotEmpty, Boolean showUI) [0x00000] in <filename unknown>:0
    7. at Microsoft.VisualBasic.FileIO.FileSystem.DeleteDirectory (System.String directory, DeleteDirectoryOption onDirectoryNotEmpty) [0x00000] in <filename unknown>:0
    8. at Microsoft.VisualBasic.MyServices.FileSystemProxy.DeleteDirectory (System.String directory, DeleteDirectoryOption onDirectoryNotEmpty) [0x00000] in <filename unknown>:0
    9. at consoleRelay.GPIO.clear () [0x00000] in <filename unknown>:0
    10. at consoleRelay.Module1.definePins () [0x00000] in <filename unknown>:0
    11. at consoleRelay.Module1.shellGui () [0x00000] in <filename unknown>:0
    12. at consoleRelay.Module1.Main () [0x00000] in <filename unknown>:0
    13. [ERROR] FATAL UNHANDLED EXCEPTION: System.UnauthorizedAccessException: Access to the path "/sys/class/gpio/gpiochip0/subsystem/gpiochip0/subsystem/gpiochip0/subsystem/gpiochip0/subsystem/gpiochip0/subsystem/gpiochip0/subsystem/gpiochip0/subsystem/gpiochip0/subsystem/gpiochip0/subsystem/gpiochip0/subsystem/gpiochip0/subsystem/gpiochip0/subsystem/gpiochip0/subsystem/gpiochip0/subsystem/gpiochip0/subsystem/gpiochip0/subsystem/gpiochip0/subsystem/gpiochip0/subsystem/gpiochip0/subsystem/gpiochip0/subsystem/unexport" is denied.
    14. at System.IO.File.Delete (System.String path) [0x00000] in <filename unknown>:0
    15. at Microsoft.VisualBasic.FileIO.FileSystemOperation.DeleteItem (Microsoft.VisualBasic.FileIO.Info Info, Int32 Counter, Boolean DoUpdate) [0x00000] in <filename unknown>:0
    16. at Microsoft.VisualBasic.FileIO.FileSystemOperation.Delete () [0x00000] in <filename unknown>:0
    17. at Microsoft.VisualBasic.FileIO.FileSystemOperation.ExecuteDirDelete () [0x00000] in <filename unknown>:0
    18. at Microsoft.VisualBasic.FileIO.FileSystem.DeleteDirectory (System.String directory, UIOption showUIOption, RecycleOption recycle, UICancelOption onUserCancel, DeleteDirectoryOption onDirectoryNotEmpty, Boolean showUI) [0x00000] in <filename unknown>:0
    19. at Microsoft.VisualBasic.FileIO.FileSystem.DeleteDirectory (System.String directory, DeleteDirectoryOption onDirectoryNotEmpty) [0x00000] in <filename unknown>:0
    20. at Microsoft.VisualBasic.MyServices.FileSystemProxy.DeleteDirectory (System.String directory, DeleteDirectoryOption onDirectoryNotEmpty) [0x00000] in <filename unknown>:0
    21. at consoleRelay.GPIO.clear () [0x00000] in <filename unknown>:0
    22. at consoleRelay.Module1.definePins () [0x00000] in <filename unknown>:0
    23. at consoleRelay.Module1.shellGui () [0x00000] in <filename unknown>:0
    24. at consoleRelay.Module1.Main () [0x00000] in <filename unknown>:0


    //edit :
    Und nochmal edit :D
    hier noch der code der Funktion :

    VB.NET-Quellcode

    1. Public Function definePin(ByVal pinID As Integer, ByVal direction As String, ByVal relay As Boolean)
    2. Console.ForegroundColor = ConsoleColor.DarkMagenta
    3. Console.WriteLine("Defining Pin " & pinID & " as " & direction & " - SongleRelayMode : " & relay.ToString)
    4. If direction = "in" Or direction = "out" Then
    5. Dim powetToInt As Integer = 0
    6. ' PINdirection(pinID) = direction
    7. If debugmode = True Then
    8. My.Computer.FileSystem.CreateDirectory(debugDir & "gpio" & pinID)
    9. Dim fw As IO.StreamWriter = New System.IO.StreamWriter(debugDir & "gpio" & pinID & "\direction")
    10. fw.Write(direction)
    11. fw.Close()
    12. fw = New System.IO.StreamWriter(debugDir & "gpio" & pinID & "\value")
    13. fw.Write(powetToInt)
    14. fw.Close()
    15. End If
    16. If debugmode = False Then
    17. My.Computer.FileSystem.CreateDirectory(mainDir & "gpio" & pinID)
    18. Dim fw As IO.StreamWriter = New System.IO.StreamWriter(mainDir & "mainDir" & pinID & "/direction")
    19. fw.Write(direction)
    20. fw.Close()
    21. fw = New System.IO.StreamWriter(mainDir & "gpio" & pinID & "/value")
    22. fw.Write(powetToInt)
    23. fw.Close()
    24. End If
    25. ElseIf direction = "relay" Then
    26. Dim powetToInt As Integer = 0
    27. ' PINdirection(pinID) = direction
    28. If debugmode = True Then
    29. Console.WriteLine(mainDir & "gpio" & pinID)
    30. My.Computer.FileSystem.CreateDirectory(debugDir & "gpio" & pinID)
    31. Dim fw As IO.StreamWriter = New System.IO.StreamWriter(debugDir & "gpio" & pinID & "\direction")
    32. fw.Write("out")
    33. fw.Close()
    34. fw = New System.IO.StreamWriter(debugDir & "gpio" & pinID & "\value")
    35. fw.Write(1)
    36. fw.Close()
    37. End If
    38. If debugmode = False Then
    39. Console.WriteLine(mainDir & "gpio" & pinID)
    40. My.Computer.FileSystem.CreateDirectory(mainDir & "gpio" & pinID)
    41. Dim fw As IO.StreamWriter = New System.IO.StreamWriter(mainDir & "gpio" & pinID & "/direction")
    42. fw.Write("out")
    43. fw.Close()
    44. fw = New System.IO.StreamWriter(mainDir & "gpio" & pinID & "/value")
    45. fw.Write(1)
    46. fw.Close()
    47. End If
    48. End If
    49. Console.ForegroundColor = ConsoleColor.Green
    50. Console.WriteLine("Pin defined succesfuly")
    51. End Function


    Achse und ich führe es mitsudo mono '/home/nas/consoleRelay.exeaus :)

    Dieser Beitrag wurde bereits 2 mal editiert, zuletzt von „meyer0815“ ()

    Mach mal Option Strict On und bessere auftauchende Fehler aus.
    Dann schau dir mal den Pfad der in der Fehlermeldung genannt wird an - der ist gefühlte 3km lang^^ Da musst du irgendwo einen Fehler haben, vermutlich in einer anderen Methode. Ansonsten ist dein Code auch nicht sehr sauber programmiert, viele String-Vergleiche (Enums sind hier oft gute Alternativen), du schreibst oft gleichen/gleichartigen Code, du verwendest / sowie \ zum trennen der Pfadangaben - da reagieren UNIX-System oft unfreundlich (IO.Path.Combine sollte das richtig machen), der böse My-Namespace,...

    Am besten du sagst uns mal was der Code genau machen soll.
    naja also der code soll den GPIO port am raspberry definieren und das wars dann auch

    also mit in / out definiert er ihn standartmäsing und mit relays definiert er den pin auch standardmäßig , halt nur das er den wert anfangs nicht auf 0 sondern auf 1 setzt .

    also der code soll eigentlich diese Konsole-commands ersetzen : echo "out" > /sys/class/gpio/export ; echo 1 > sys/class/gpio/gpio(Pin)/value

    :D
    ich hoffe man ann versehen was ich meine :D

    //edit :
    verbesserter code :

    VB.NET-Quellcode

    1. Public Function definePin2(ByVal pinID As Integer, ByVal pinMode As Integer)
    2. 'writer definieren
    3. Dim fw As IO.StreamWriter
    4. 'pfad erstellen
    5. Dim path = ""
    6. Dim Seperator As String = ""
    7. 'GPIO pfad erstellen
    8. My.Computer.FileSystem.CreateDirectory(path & "gpio" & pinID)
    9. 'variablen füllen
    10. If debugmode = False Then
    11. path = mainDir
    12. Seperator = "/"
    13. Else
    14. path = debugDir
    15. Seperator = ""
    16. End If
    17. 'pin mode
    18. Select Case pinMode
    19. Case "in"
    20. fw = New System.IO.StreamWriter(mainDir & "gpio" & pinID & "/direction")
    21. fw.Write("in")
    22. fw.Close()
    23. fw = New System.IO.StreamWriter(mainDir & "gpio" & pinID & "/value")
    24. fw.Write(0)
    25. fw.Close()
    26. Case "out"
    27. fw = New System.IO.StreamWriter(mainDir & "gpio" & pinID & "/direction")
    28. fw.Write("out")
    29. fw.Close()
    30. fw = New System.IO.StreamWriter(mainDir & "gpio" & pinID & "/value")
    31. fw.Write(0)
    32. fw.Close()
    33. Case "relay"
    34. fw = New System.IO.StreamWriter(mainDir & "gpio" & pinID & "/direction")
    35. fw.Write("out")
    36. fw.Close()
    37. fw = New System.IO.StreamWriter(mainDir & "gpio" & pinID & "/value")
    38. fw.Write(1)
    39. fw.Close()
    40. End Select
    41. End Function

    Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von „meyer0815“ ()

    so nochmal editiert und geht immer noch net :

    VB.NET-Quellcode

    1. Public Function definePin2(ByVal pinID As Integer, ByVal pinMode As String) as ???
    2. 'writer definieren
    3. Dim fw As IO.StreamWriter
    4. 'pfad erstellen
    5. Dim path = ""
    6. 'variablen füllen
    7. If debugmode = False Then
    8. path = mainDir
    9. Else
    10. path = debugDir
    11. End If
    12. 'GPIO pfad erstellen
    13. My.Computer.FileSystem.CreateDirectory(path & "gpio" & pinID)
    14. 'pin mode
    15. Select Case pinMode
    16. Case "in"
    17. fw = New System.IO.StreamWriter(mainDir & "gpio" & pinID & "/direction")
    18. fw.Write("in")
    19. fw.Close()
    20. Case "out"
    21. fw = New System.IO.StreamWriter(mainDir & "gpio" & pinID & "/direction")
    22. fw.Write("out")
    23. fw.Close()
    24. fw = New System.IO.StreamWriter(mainDir & "gpio" & pinID & "/value")
    25. fw.Write(0)
    26. fw.Close()
    27. Case "relay"
    28. fw = New System.IO.StreamWriter(mainDir & "gpio" & pinID & "/direction")
    29. fw.Write("out")
    30. fw.Close()
    31. fw = New System.IO.StreamWriter(mainDir & "gpio" & pinID & "/value")
    32. fw.Write(1)
    33. fw.Close()
    34. End Select
    35. End Function
    36. End Module


    was muss man eigentlic schreiben wenn eine function nichts zurrückgeben soll ?
    --edit---

    :D :D :D :D :D :D :D :D :D :D :D :D :D :D
    es geht !! :) super es funktioniert also port 1-6 und die letzten beiden bekomme ich auch noch hin :)

    --original---
    okay ich habe alles nochmal überarbeitet und bekomme jetzt nur noch

    Unhandled Exception: System.IO.IOException: Lock violation on path /sys/class/gpio/export
    at System.IO.FileStream.FlushBuffer (System.IO.Stream st) [0x00000] in <filename unknown>:0
    at System.IO.FileStream.FlushBuffer () [0x00000] in <filename unknown>:0
    at System.IO.FileStream.Flush () [0x00000] in <filename unknown>:0
    at System.IO.StreamWriter.Flush () [0x00000] in <filename unknown>:0
    at System.IO.StreamWriter.Dispose (Boolean disposing) [0x00000] in <filename unknown>:0
    [ERROR] FATAL UNHANDLED EXCEPTION: System.IO.IOException: Lock violation on path /sys/class/gpio/export
    at System.IO.FileStream.FlushBuffer (System.IO.Stream st) [0x00000] in <filename unknown>:0
    at System.IO.FileStream.FlushBuffer () [0x00000] in <filename unknown>:0
    at System.IO.FileStream.Flush () [0x00000] in <filename unknown>:0
    at System.IO.StreamWriter.Flush () [0x00000] in <filename unknown>:0
    at System.IO.StreamWriter.Dispose (Boolean disposing) [0x00000] in <filename unknown>:0

    zurück.

    VB.NET-Quellcode

    1. Public Sub definePin2(ByVal pinID As Integer, ByVal pinMode As String)
    2. Console.WriteLine(mainDir.ToString)
    3. 'writer definieren
    4. Dim fw As IO.StreamWriter
    5. 'pfad erstellen
    6. Dim path As String = ""
    7. 'variablen füllen
    8. path = "/sys/class/gpio/"
    9. 'GPIO pfad erstellen
    10. ' My.Computer.FileSystem.CreateDirectory(path & "gpio" & pinID)
    11. fw = New System.IO.StreamWriter(path & "export")
    12. fw.WriteLine(pinID)
    13. fw.Close()
    14. 'pin mode
    15. Select Case pinMode
    16. Case "in"
    17. fw = New System.IO.StreamWriter(path & "gpio" & pinID & "/direction")
    18. fw.WriteLine("in")
    19. fw.Close()
    20. Case "out"
    21. fw = New System.IO.StreamWriter(path & "gpio" & pinID & "/direction")
    22. fw.WriteLine("out")
    23. fw.Close()
    24. fw = New System.IO.StreamWriter(path & "gpio" & pinID & "/value")
    25. fw.Write("0")
    26. fw.Close()
    27. Case "relay"
    28. fw = New System.IO.StreamWriter(path & "gpio" & pinID & "/direction")
    29. fw.WriteLine("out")
    30. fw.Close()
    31. fw = New System.IO.StreamWriter(path & "gpio" & pinID & "/value")
    32. fw.Write("0")
    33. fw.Close()
    34. End Select
    35. End Sub

    Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von „meyer0815“ ()