elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Trabajando con las ramas de git (tercera parte)


  Mostrar Mensajes
Páginas: 1 ... 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 [1017] 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 ... 1236
10161  Programación / .NET (C#, VB.NET, ASP) / Re: Cuando compilo mi aplicación, no funciona. en: 21 Noviembre 2012, 18:54 pm
(Perdón por el doble post)

Código
  1.    Private Sub CargarPropiedades()
  2.        If Not IsNothing(My.Settings.Valores) Then
  3.            Dim ListaCheckados As Int32() = My.Settings.Valores
  4.            For i As Int32 = 0 To mcheck.Length - 1
  5.                For Each indiceCheckado As Int32 In ListaCheckados
  6.                    mcheck(indiceCheckado - 1).Checked = True
  7.                Next
  8.            Next
  9.        End If
  10.    End Sub

Pero me sigue enviando otro tipo de errores:

Código:
************** Exception Text **************
System.ArgumentException: The property 'Valores' could not be created from it's default value. Error message: There is an error in XML document (1, 1).
   at System.Configuration.SettingsPropertyValue.Deserialize()
   at System.Configuration.SettingsPropertyValue.get_PropertyValue()
   at System.Configuration.SettingsBase.GetPropertyValueByName(String propertyName)
   at System.Configuration.SettingsBase.get_Item(String propertyName)
   at System.Configuration.ApplicationSettingsBase.GetPropertyValue(String propertyName)
   at System.Configuration.ApplicationSettingsBase.get_Item(String propertyName)
   at PlayLists.My.MySettings.get_Valores() in C:\Users\Administrador\Desktop\WindowsApplication19\My Project\Settings.Designer.vb:line 86
   at PlayLists.Form1.CargarPropiedades() in C:\Users\Administrador\Desktop\WindowsApplication19\Form1.vb:line 107
   at PlayLists.Form1.Form1_Load(Object sender, EventArgs e) in C:\Users\Administrador\Desktop\WindowsApplication19\Form1.vb:line 60
   at System.EventHandler.Invoke(Object sender, EventArgs e)
   at System.Windows.Forms.Form.OnLoad(EventArgs e)
   at System.Windows.Forms.Form.OnCreateControl()
   at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
   at System.Windows.Forms.Control.CreateControl()
   at System.Windows.Forms.Control.WmShowWindow(Message& m)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
   at System.Windows.Forms.ContainerControl.WndProc(Message& m)
   at System.Windows.Forms.Form.WmShowWindow(Message& m)
   at System.Windows.Forms.Form.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

Intento empezar por el siguiente error pero...
Código:
System.ArgumentException: The property 'Valores' could not be created from it's default value. Error message: There is an error in XML document (1, 1).

¿A que documento XML se refiere? ¿y como es posible que me diga que el error está en el caracter 1 de la columna 1? suena imposible...

EDITO:
Código:
   at PlayLists.Form1.CargarPropiedades() in C:\Users\Administrador\Desktop\WindowsApplication19\Form1.vb:line 107

línea 107:
Código
  1.        If Not IsNothing(My.Settings.Valores) Then

Venga ya...  :¬¬ :¬¬ :¬¬
10162  Programación / .NET (C#, VB.NET, ASP) / Re: Cuando compilo mi aplicación, no funciona. en: 21 Noviembre 2012, 18:31 pm
Código
  1. If IsNothing(My.Settings.Valores) then
  2. 'llamas al Sub
  3. End If
lo he intentado, pero creo que no lo hago bien.


He descubierto que la excepción de la consola aparece solamente cuando cierro el form sin que haya ningún checkbox clickado, y me dice la consola lo de "IndexOutOf..."

Si ejecuto la app (compilada) sin que haya ningún checkbox seleccionado (por ejemplo el primer uso) pues me manda error, pero si habia algún checkbox seleccionado no me sale la ventana de error...
En cambio, si ejecuto la app desde la IDE sin que haya ningún checkbox clickado, la consola no dice nada de excepciones, pero si lo hago desde la app compilada con esas circunstancias si, es un poco raro ¿no?

Pon un punto de interrupción y le pasas el mouse por arriba :xD

Saludos

Que significa para ti pasarle el mouse por arriba?, yo le pongo el breakpoint, pero...y luego? xD
10163  Programación / .NET (C#, VB.NET, ASP) / Re: Cuando compilo mi aplicación, no funciona. en: 21 Noviembre 2012, 17:50 pm
Cuando abres la app por 1ª vez, ¿cómo está inicializado My.Settings.Valores ?
No se si te refieres a esto, es Int32, con valor "0"

Podrías crearte un Sub con el código que metes en el FormClosing y ese Sub meterlo en Load llámandolo antes del CargaPropiedades, si My.Settings.Valores no está inicializado.
¿Y como compruebo si está inicializada?
Yo he intentado un:
Código
  1. MsgBox(My.Settings.Valores.ToString())
para ver si es "0", pero no se ejecuta el msgbox (ni el resto de código que sigue debajo).
10164  Programación / .NET (C#, VB.NET, ASP) / Re: La carpeta bin se me llena de dll's que mi app no utiliza en: 21 Noviembre 2012, 17:33 pm
¿Solo son controles que fuiste agregando?
si

Intenta dando botón derecho sobre la solución, hay una opción de "clean solution" (limpiar solución), y luego vuelve a compilar

Ya lo hice Nov, me borra las dll de la carpeta (en realidad me borra todo lo que haya en la carpeta...), y cuando vuelvo a compilar desde la IDE vuelve a agregar todas esas dll a la carpeta, y no me deja ejecutar el .exe sin esas dll  :xD

Quizás es una tontería pero por si tiene algo que ver, estoy en modo "debug", no "release".

saludos
10165  Programación / .NET (C#, VB.NET, ASP) / Re: ¿Como hacer el .exe para todos los ordenadores? (Visual Basics 2012)? en: 21 Noviembre 2012, 17:30 pm
Aun no me deja, por lo menos me sale que dejo de responder pero sige sin ir.  :-(

No es que no tengan el visual basic, es que no tienen el .net framework..

@enriquefemo
Si no entendiste esa parte dilo, debes instalar en tu PC (y en los otros) la versión adecuada de Framework...
De todas formas si cambias en las propiedades el framework a 2.0 dudo que te siga sin funcionar en winxp/vista/7/8 ...

http://www.microsoft.com/es-es/download/details.aspx?id=30653
10166  Programación / .NET (C#, VB.NET, ASP) / Re: ¿Como hacer el .exe para todos los ordenadores? (Visual Basics 2012)? en: 21 Noviembre 2012, 17:08 pm
No soy ningún experto pero en las propiedades del programa puedes requerir una versión inferior del framework:



Saludos
10167  Programación / .NET (C#, VB.NET, ASP) / (solucionado) La carpeta bin se me llena de dll's que mi app no utiliza en: 21 Noviembre 2012, 17:02 pm


Todas esas dlls controles en realidad mi app no las utiliza, las añadí a mi form para ver lo que hacian y si me podian servir para algún propósito, pero después de eso las eliminé (usando el botón eliminar)

¿Donde debo borrar los rastros que quedan de esas dll's?

¿Hay alguna extensión para VS2012 que haga esto automáticamente por mi?

Saludos
10168  Programación / .NET (C#, VB.NET, ASP) / Re: Cuando compilo mi aplicación, no funciona. en: 21 Noviembre 2012, 16:59 pm
Coloca el código que esta en Form_Load, nunca digas que no puedes hacer algo, aquí todos comenzamos con Hola Mundo, y como tu puedes ver ya has avanzado ¿o no? ;) No te rindas tan fácilmente se necesita mucha perseverancia para terminar un proyecto precisamente por la paciencia que hay que tener para hallar y solucionar los errores.

Gracias.

Pues mejor pongo todo el form (Aún le estoy retocando lo del Drag&Drop):

Código
  1. Imports System.Windows.Forms
  2. Imports System.IO
  3.  
  4. Public Class Form1
  5.    Dim filesystem As Object, ThisDir As Object
  6.    Dim mcheck(0) As CheckBox
  7.    Dim playerargs As String
  8.  
  9.  
  10. #Region "Propertys"
  11.  
  12.    'userSelectedPlayerFilePath
  13.    Public Property userSelectedPlayerFilePath() As String
  14.        Get
  15.            Return playertextbox.Text
  16.        End Get
  17.        Set(value As String)
  18.            playertextbox.Text = value
  19.        End Set
  20.    End Property
  21.  
  22.    ' userSelectedFolderPath
  23.    Public Property userSelectedFolderPath() As String
  24.        Get
  25.            Return foldertextbox.Text
  26.        End Get
  27.        Set(value As String)
  28.            foldertextbox.Text = value
  29.        End Set
  30.    End Property
  31.  
  32. #End Region
  33.  
  34. #Region "Load / Close"
  35.  
  36.    ' Form load
  37.    Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
  38.        Try
  39.  
  40.            Me.Text = My.Settings.APPName & " - By Elektro H@cker"
  41.  
  42.            If Not My.Computer.FileSystem.DirectoryExists(My.Settings.folderpath) Then
  43.                foldertextbox.Text = "Selext a folder..."
  44.                Me.Size = New System.Drawing.Size(362, 228)
  45.                Panel1.Size = New System.Drawing.Size(0, 0)
  46.                My.Settings.folderpath = Nothing
  47.                My.Settings.Save()
  48.            Else
  49.                foldertextbox.Text = My.Settings.folderpath
  50.            End If
  51.  
  52.            If Not My.Computer.FileSystem.FileExists(My.Settings.playerpath) Then
  53.                playertextbox.Text = "Selext a music player..."
  54.                My.Settings.playerpath = Nothing
  55.                My.Settings.Save()
  56.            Else
  57.                playertextbox.Text = My.Settings.playerpath
  58.            End If
  59.  
  60.            updatecheckboxes()
  61.            CargarPropiedades()
  62.        Catch
  63.  
  64.        End Try
  65.  
  66.    End Sub
  67.  
  68.    ' Form close
  69.    Private Sub Form1_FormClosing(sender As Object, e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
  70.        Dim mCheckados(0) As Int32
  71.        Dim Cuantos As Int32 = 0
  72.        Dim empty = Nothing
  73.  
  74.        For Each c As CheckBox In Panel1.Controls
  75.            empty = "no"
  76.        Next
  77.        If Not empty = "no" Then
  78.            My.Settings.Valores = Nothing
  79.        Else
  80.            For i As Int32 = 0 To mcheck.Length - 1
  81.                If mcheck(i).Checked = True Then
  82.                    Cuantos += 1
  83.                    Array.Resize(mCheckados, Cuantos)
  84.                    mCheckados(Cuantos - 1) = i + 1
  85.                End If
  86.            Next
  87.            My.Settings.Valores = mCheckados
  88.        End If
  89.  
  90.        My.Settings.Save()
  91.    End Sub
  92.  
  93. #End Region
  94.  
  95.  
  96. #Region "Save / Get settings"
  97.  
  98.    ' Generate propertys
  99.    Public Sub GenerarPropiedades()
  100.        Dim CheckedN As String = Nothing
  101.        For i As Int32 = 0 To mcheck.Length - 1
  102.            If mcheck(i).Checked = True Then
  103.                CheckedN &= i + 1
  104.            End If
  105.        Next
  106.        My.Settings.Save()
  107.    End Sub
  108.  
  109.    ' load propertys
  110.    Private Sub CargarPropiedades()
  111.        Dim ListaCheckados As Int32() = My.Settings.Valores
  112.        For i As Int32 = 0 To mcheck.Length - 1
  113.            For Each indiceCheckado As Int32 In ListaCheckados
  114.                mcheck(indiceCheckado - 1).Checked = True
  115.            Next
  116.        Next
  117.    End Sub
  118.  
  119. #End Region
  120.  
  121.  
  122. #Region "Checkboxes"
  123.  
  124.    ' Checkbox drawing
  125.    Public Sub updatecheckboxes()
  126.        ' delete the old checkboxes
  127.        Panel1.Controls.Clear()
  128.        ' create the new checkboxes
  129.        Dim filesystem = CreateObject("Scripting.FileSystemObject")
  130.        Dim ThisDir = filesystem.GetFolder(My.Settings.folderpath)
  131.        Dim i As Int32 = 0
  132.        Dim pos As Int32 = 10
  133.        For Each folder In ThisDir.Subfolders
  134.            Array.Resize(mcheck, i + 1)
  135.            mcheck(i) = New CheckBox
  136.            With mcheck(i)
  137.                .AutoSize = True
  138.                .Location = New Point(10, pos)
  139.                .Name = "CheckBox" & i + 1
  140.                .Text = folder.Name
  141.            End With
  142.            Me.Panel1.Controls.Add(mcheck(i))
  143.            AddHandler mcheck(i).CheckedChanged, AddressOf LlamadaCheckBox
  144.            i += 1
  145.            pos += 20
  146.        Next
  147.  
  148.    End Sub
  149.  
  150.    ' Checkbox events
  151.    Public Sub LlamadaCheckBox(ByVal sender As Object, ByVal e As System.EventArgs)
  152.        Dim filesystem = CreateObject("Scripting.FileSystemObject")
  153.        Dim ThisDir = filesystem.GetFolder(My.Settings.folderpath)
  154.        Dim CheckboxN As CheckBox = CType(sender, CheckBox)
  155.        If CheckboxN.Checked = True Then
  156.            playerargs = playerargs & " " & ControlChars.Quote & Path.Combine(ThisDir.Path, CheckboxN.Text.ToString()) & ControlChars.Quote
  157.        Else
  158.            playerargs = Replace(playerargs, " " & ControlChars.Quote & Path.Combine(ThisDir.Path, CheckboxN.Text.ToString()) & ControlChars.Quote, "")
  159.        End If
  160.    End Sub
  161.  
  162. #End Region
  163.  
  164.  
  165. #Region "Buttons"
  166.  
  167.    ' Folder button
  168.    Public Sub C1Button3_Click(sender As Object, e As EventArgs) Handles folderbutton.Click
  169.        Dim folderselected As New System.Windows.Forms.FolderBrowserDialog
  170.        Dim Resultado As DialogResult
  171.        folderselected.RootFolder = Environment.SpecialFolder.Desktop
  172.        Resultado = folderselected.ShowDialog
  173.        If Resultado.ToString() = "OK" Then
  174.            userSelectedFolderPath = folderselected.SelectedPath
  175.            My.Settings.folderpath = folderselected.SelectedPath
  176.            My.Settings.Save()
  177.            playerargs = Nothing
  178.            Me.Size = New System.Drawing.Size(362, 540)
  179.            Panel1.Size = New System.Drawing.Size(322, 296)
  180.            updatecheckboxes()
  181.        End If
  182.    End Sub
  183.  
  184.    ' Player button
  185.    Public Sub C1Button1_Click(sender As Object, e As EventArgs) Handles playerbutton.Click
  186.        Dim playerselected As New OpenFileDialog()
  187.        playerselected.InitialDirectory = Environ("programfiles")
  188.        playerselected.Title = "Select your favorite music player"
  189.        playerselected.Filter = "Music players|bsplayer.exe;mpc.exe;mpc-hc.exe;mpc-hc64.exe;umplayer.exe;vlc.exe;winamp.exe;wmp.exe"
  190.        PlayerDialog.FilterIndex = 1
  191.        Dim selection As System.Windows.Forms.DialogResult = playerselected.ShowDialog()
  192.        If selection = DialogResult.OK Then
  193.            userSelectedPlayerFilePath = playerselected.FileName
  194.            My.Settings.playerpath = playerselected.FileName
  195.            My.Settings.Save()
  196.        End If
  197.    End Sub
  198.  
  199.    ' Play button
  200.    Public Sub C1Button2_Click(sender As Object, e As EventArgs) Handles playbutton.Click
  201.        If Not playerargs = Nothing Then
  202.            Process.Start(userSelectedPlayerFilePath, playerargs)
  203.            If autoclose.Checked = True Then
  204.                Me.Close()
  205.            End If
  206.        Else
  207.            MessageBox.Show("You must select at least one folder...", My.Settings.APPName)
  208.        End If
  209.    End Sub
  210.  
  211.    ' Select  ALL checkboxes
  212.    Private Sub CheckBox1_CheckedChanged(sender As Object, e As EventArgs) Handles selectall.CheckedChanged
  213.        If selectall.Checked = False Then
  214.            For Each ctrl In Panel1.Controls
  215.                ctrl.Checked = False
  216.            Next
  217.            selectall.Text = "Select all"
  218.        Else
  219.            For Each ctrl In Panel1.Controls
  220.                ctrl.Checked = True
  221.            Next
  222.            selectall.Text = "Unselect all"
  223.        End If
  224.    End Sub
  225.  
  226. #End Region
  227.  
  228.  
  229. #Region "Drag & Drop"
  230.  
  231.  
  232.  
  233.  
  234.    Private Sub Panel1_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles Panel1.DragDrop
  235.        If e.Data.GetDataPresent(DataFormats.FileDrop) Then
  236.            Dim Objetos As String() = e.Data.GetData(DataFormats.FileDrop)
  237.            Panel1.Text = Objetos(0)
  238.            userSelectedFolderPath = Objetos(0)
  239.            My.Settings.folderpath = Objetos(0)
  240.            My.Settings.Save()
  241.            playerargs = Nothing
  242.            updatecheckboxes()
  243.        End If
  244.    End Sub
  245.  
  246.    Private Sub Panel1_DragEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles Panel1.DragEnter
  247.        If e.Data.GetDataPresent(DataFormats.FileDrop) Then
  248.            e.Effect = DragDropEffects.All
  249.        End If
  250.    End Sub
  251.  
  252.   Private Sub TextBox1_DragDrop(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles foldertextbox.DragDrop
  253.        If e.Data.GetDataPresent(DataFormats.FileDrop) Then
  254.            Dim Objetos As String() = e.Data.GetData(DataFormats.FileDrop)
  255.  
  256.            Dim attributes = Objetos(0)
  257.            If ((attributes And FileAttributes.Directory) = FileAttributes.Directory) Then
  258.                MsgBox("es un dir")
  259.            Else
  260.                MsgBox("no es un dir")
  261.            End If
  262.  
  263.            foldertextbox.Text = Objetos(0)
  264.            userSelectedFolderPath = Objetos(0)
  265.            My.Settings.folderpath = Objetos(0)
  266.            My.Settings.Save()
  267.            playerargs = Nothing
  268.            updatecheckboxes()
  269.        End If
  270.    End Sub
  271.  
  272.    Private Sub TextBox1_DragEnter(ByVal sender As Object, ByVal e As System.Windows.Forms.DragEventArgs) Handles foldertextbox.DragEnter
  273.        If e.Data.GetDataPresent(DataFormats.FileDrop) Then
  274.            e.Effect = DragDropEffects.All
  275.        End If
  276.    End Sub
  277.  
  278. #End Region
  279.  
  280.  
  281. End Class
10169  Programación / .NET (C#, VB.NET, ASP) / Re: Cuando compilo mi aplicación, no funciona. en: 21 Noviembre 2012, 16:51 pm
Es mala practica no controlar los errores, debes manejar todas las excepciones, validar absolutamente todo.

Tienes toda la razón, es mala práctica, pero pienso que para solventar ese tipo de cosas hay que tener mejor dominio del lenguaje, del que tengo yo.

Un saludo!
10170  Programación / .NET (C#, VB.NET, ASP) / Re: Cuando compilo mi aplicación, no funciona. en: 21 Noviembre 2012, 16:35 pm
Esa ventana es aviso de una excepción no controlada, si lees da mucha información acerca de donde y como se dio el error, tienes que revisar el código en el lugar donde te dice que lo hubo, buscando valores inválidos, variables no inicializadas, divisiones por 0, desbordamientos y ese tipo de cosas.

Gracias, pero entonces no se puede desactivar ese tipo de avisos desde el "app.config" o en algún sitio?


EDITO: Te agradezco mucho los datos que me has dado pero no me apetece nada buscar " divisiones por 0, desbordamientos" porque nos e hacerlo, y la app funciona perfectamente aunque el debugger me diga que no.

Lo he arreglado de una manera más fácil, añadiendo una excepción en el form load.  :xD

Un saludo
Páginas: 1 ... 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 [1017] 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 ... 1236
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines