[Mono-bugs] [Bug 505042] New: i can't run those kind of programe

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Mon May 18 21:21:33 EDT 2009


http://bugzilla.novell.com/show_bug.cgi?id=505042


           Summary: i can't run those kind of programe
    Classification: Mono
           Product: Mono: Runtime
           Version: 2.2.x
          Platform: x86
        OS/Version: Linux
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: debug
        AssignedTo: martin at novell.com
        ReportedBy: axlrose112 at gmail.com
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---


User-Agent:       Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.10)
Gecko/2009050804 Mandriva/1.9.0.10-0.1mdv2009.1 (2009.1) Firefox/3.0.10

                       this is my VB.NET code


Module indexe

    Public Structure etudiant

        <VBFixedString(4)> Dim code As String

        <VBFixedString(10)> Dim nom As String

        <VBFixedString(10)> Dim prenom As String

        <VBFixedString(20)> Dim salb As Double

        <VBFixedString(25)> Dim salbr As Double

        <VBFixedString(25)> Dim salnet As Double

        <VBFixedString(5)> Dim anc As Double

        <VBFixedString(15)> Dim nbrh As Double

        <VBFixedString(15)> Dim txh As Double

        <VBFixedString(15)> Dim ret As Double

    End Structure

    Dim FileNum As Integer

    Dim unetudiant As etudiant

    Dim L As Integer = Len(unetudiant)

    Dim t() As etudiant

    Sub ajout()

        FileOpen(1, "Fichier.txt", OpenMode.Random, , , L)

        Console.Write("entrer le code:")

        unetudiant.code = Console.ReadLine()

        Console.Write("entrer le nom:")

        unetudiant.nom = Console.ReadLine()

        Console.Write("entrer le prénom:")

        unetudiant.prenom = Console.ReadLine()

        Console.Write("entrer la nombre d'heure:")

        unetudiant.nbrh = Console.ReadLine()

        Console.Write("entrer le taux horaire:")

        unetudiant.txh = Console.ReadLine()

        Console.Write("entrer l'ancienté:")



        unetudiant.anc = Console.ReadLine()

        Console.WriteLine("entrez le retenue ")

        unetudiant.ret = Console.ReadLine

        unetudiant.salb = unetudiant.txh * unetudiant.nbrh



        If unetudiant.anc < 10 Then

            unetudiant.salbr = unetudiant.salb * (1 + 10 / 100)

        End If

        If unetudiant.anc > 20 Then

            unetudiant.salbr = unetudiant.salb * (1 + 35 / 100)

        End If

        If unetudiant.anc > 10 And unetudiant.anc < 20 Then

            unetudiant.salbr = unetudiant.salb * (1 + 20 / 100)

        End If

        unetudiant.salnet = unetudiant.salbr - unetudiant.ret

        Dim last As Integer = FileLen("fichier.txt") / L

        FilePut(1, unetudiant, last + 1)

        FileClose(1)

    End Sub

    Public Sub afficher()

        Dim i As Integer = 1

        FileOpen(1, "Fichier.txt", OpenMode.Random, , , L)

       
Console.WriteLine("___________________________________________________________________")

        Console.WriteLine("code   Nom   prénom   Salaire base   salaire brute  
salaire net")

       
Console.WriteLine("___________________________________________________________________")

        While Not EOF(1)

            FileGet(1, unetudiant, i)

            Dim a As String = (unetudiant.code & "           ").Substring(0, 6)

            Dim b As String = (unetudiant.nom & "           ").Substring(0, 7)

            Dim c As String = (unetudiant.prenom & "        ").Substring(0, 13)

            Dim d As String = (unetudiant.salb & "          ").Substring(0, 10)

            Dim e As String = (unetudiant.salbr & "         ").Substring(0, 8)

            Dim f As String = (unetudiant.salnet & "        ").Substring(0, 8)



            i = i + 1

            Console.WriteLine(a & b & c & d & e & f)

        End While

        FileClose(1)



    End Sub



    Sub rechercher()

        Dim rech As Boolean = False

        Dim i As Integer = 1

        Console.WriteLine("entrer le code a chercher")

        Dim code As String = Console.ReadLine()

        FileOpen(1, "fichier.txt", OpenMode.Random, , , L)

        While Not EOF(1)

            FileGet(1, unetudiant, i)

            If Trim(unetudiant.code) = code Then

                Console.WriteLine("l'agent recherché est:" & unetudiant.nom & "
" & unetudiant.prenom)

                rech = True

                Exit While

            End If

            i = i + 1

        End While

        If rech = False Then

            Console.WriteLine("agent non trouvé")

        End If

        FileClose(1)

    End Sub

    Sub supprimer()

        Dim i As Integer = 1

        Dim j As Integer = 1

        Dim sup As Boolean = False

        Console.WriteLine("entrer la matricule a supprimer")

        Dim code As String = Console.ReadLine()

        FileOpen(1, "fichier.txt", OpenMode.Random, , , L)

        While Not EOF(1)

            FileGet(1, unetudiant, i)

            If Trim(unetudiant.code) = code Then

                sup = True

                Exit While

            End If

            i = i + 1

        End While

        If sup = True Then

            i = 1

            Seek(1, 1)

            FileOpen(2, "fichiersup.txt", OpenMode.Random, , , L)

            While Not EOF(1)

                FileGet(1, unetudiant, i)

                If Trim(unetudiant.code) <> code Then

                    FilePut(2, unetudiant, j)

                    j = j + 1

                End If

                i = i + 1

            End While

            FileClose(1)

            FileClose(2)

            Kill("fichier.txt")

            Rename("fichiersup.txt", "fichier.txt")

        Else

            FileClose(1)

            Console.WriteLine("etudiant non trouvé")

        End If

    End Sub

    Sub modifier()

        Dim i As Integer = 1

        Dim j As Integer = 1

        Dim modif As Boolean = False

        Console.WriteLine("entrer le code a modifier")

        Dim code As String = Console.ReadLine()

        FileOpen(1, "fichier.txt", OpenMode.Random, , , L)

        While Not EOF(1)

            FileGet(1, unetudiant, i)

            If Trim(unetudiant.code) = code Then

                modif = True

                Exit While

            End If

            i = i + 1

        End While

        If modif = True Then

            i = 1

            Seek(1, 1)

            FileOpen(2, "fichiermodif.txt", OpenMode.Random, , , L)

            While Not EOF(1)

                FileGet(1, unetudiant, i)

                If Trim(unetudiant.code) <> code Then

                    FilePut(2, unetudiant, j)

                    j = j + 1

                End If

                i = i + 1

            End While

            Console.Write("entrer le code:")

            unetudiant.code = Console.ReadLine()

            Console.Write("entrer le nom:")

            unetudiant.nom = Console.ReadLine()

            Console.Write("entrer le prénom:")

            unetudiant.prenom = Console.ReadLine()

            Console.Write("entrer le nombre d'heure:")

            unetudiant.nbrh = Console.ReadLine()

            Console.Write("entrer le taux horaire:")

            unetudiant.txh = Console.ReadLine()

            Console.Write("entrer l'ancienté:")

            unetudiant.anc = Console.ReadLine()

            Dim last As Integer = FileLen("fichier.txt") / L

            FilePut(2, unetudiant, last)

            FileClose(1)

            FileClose(2)

            Kill("fichier.txt")

            Rename("fichiermodif.txt", "Fichier.txt")

        Else

            FileClose(1)

            Console.WriteLine("etudiant non trouvé")

        End If

    End Sub

    Sub trier()

        Dim i As Integer = 1

        Dim a, b As Double

        Dim j, k As Integer

        Dim per As Boolean = True

        Dim t() As etudiant

        Dim last As Integer = FileLen("fichier.txt") / L

        ReDim t(last)

        FileOpen(1, "Fichier.txt", OpenMode.Random, , , L)

        While Not EOF(1)

            FileGet(1, unetudiant, i)

            t(i) = unetudiant

            i = i + 1

        End While

        FileClose(1)

        Dim temp As etudiant

        While (per)

            per = False

            For j = 0 To i - 2

                a = t(j).anc

                b = t(j + 1).anc

                If (a > b) Then

                    temp = t(j)

                    t(j) = t(j + 1)

                    t(j + 1) = temp

                    per = True

                End If

            Next

        End While

        For k = i - 1 To 0 Step -1

            Console.WriteLine(t(k).code & "   " & t(k).nom & "   " &
t(k).prenom & "   " & t(k).salb & "   " & t(k).salbr & "   " & t(k).salnet)

        Next

        FileOpen(3, "fichiertrier.txt", OpenMode.Random, , , L)

        For k = 0 To i - 1

            FilePut(3, t(k), i - k)

        Next

        FileClose(3)

        Console.WriteLine("tri effectue")





    End Sub

    Sub Main()

        Dim ok As String = "oui"

        Console.WriteLine("---------------gestion des
fichiers----------------")

        Console.WriteLine("                 A : AJOUTER")

       
Console.WriteLine("---------------------------------------------------")

        Console.WriteLine("                 F : AFFICHER")

       
Console.WriteLine("---------------------------------------------------")

        Console.WriteLine("                 R : RECHERCHER")

       
Console.WriteLine("---------------------------------------------------")

        Console.WriteLine("                 S : SUPPRIMER")

       
Console.WriteLine("---------------------------------------------------")

        Console.WriteLine("                 M : MODIFIER")

       
Console.WriteLine("---------------------------------------------------")

        Console.WriteLine("                 T : TRIER")

       
Console.WriteLine("---------------------------------------------------")

        Console.WriteLine("                 Q : QUITTER")

       
Console.WriteLine("---------------------------------------------------")

        While (ok = "oui")

            Console.WriteLine("Entrer votre choix")

            Dim rep As String = Console.ReadLine()

            rep = rep.ToUpper()

            Select Case rep

                Case "A" : ajout()

                Case "F" : afficher()

                Case "R" : rechercher()

                Case "S" : supprimer()

                Case "M" : modifier()

                Case "T" : trier()

                Case "Q" : Exit Sub

            End Select

            Console.WriteLine("voulez vous choisir un autre choix:oui/non")

            ok = Console.ReadLine()

        End While

    End Sub

End Module

Reproducible: Always

Steps to Reproduce:
1.vbnc mine.vb 'Compilation successful
2.mono mine.exe 'gives me that erreur

Unhandled Exception: System.TypeInitializationException: An exception was
thrown by the type initializer for ConsoleApplication2.indexe --->
System.InvalidCastException: Cannot cast from source type to destination type.
  at Microsoft.VisualBasic.Strings.GetSize (System.Object Expression) [0x00000] 
  at Microsoft.VisualBasic.Strings.Len (System.Object Expression) [0x00000] 
  at ConsoleApplication2.indexe..cctor () [0x00000] 
  --- End of inner exception stack trace ---





When i run it in Visual studio it's work perfect

-- 
Configure bugmail: http://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.


More information about the mono-bugs mailing list