Ciao a tutti. Volevo sapere una cosa. Ho appena terminato una piccola applicazione (un quiz) con visual basic 2005. Il mio problema è che su altri pc il prog non parte se non è installato il framework 2.0. Mi chiedevo se era possibile escludere il framework, insomma, fare in modo che funzioni su tutti i pc senza problemi. L'applicazione è semplice, ci sono solo label, timer, imagelist e commandbutton. Il codice anche, semplici "if e then" e qualche ciclo. Si può fare????
Grazie 1k
Se hai generato solo un eseguibile che usa come riferimenti solo librerie di windows standard allora è tutto ok, se nella tua applicazione ci sono riferimenti a librerie caratteristiche del framework che stai utilizzando, allora devi integrarle nell'applicazione.
Insomma devi creare un pacchetto di installazione per avere la portability sulle macchine dove non è installato il framework. Se conosci le librerie, gli oggetti e i componenti utilizzati dalla tua applicazione allora puoi usare un qualsiasi tool cab assembler, altrimenti ne esiste uno integrato in VS che ti crea il pacchetto facendo tutto da solo.
Fammi sapere se hai risolto.;)
... ti riferisci forse agli oggetti tipo commandbutton, imagelist, label ecc???
Sono alle prime armi con VS, quindi scusa la mia domanda: come faccio a sapere se la mia applicazione utilizza librerie di framework (o sapere quali utilizza)???
Con la pubblicazione guidata di VS purtroppo non risolvo il problema.
Un dubbio, nella proprietà progetto, in "riferimenti" vi sono tre voci nella lista: System; System.drawing; System.windows.form. TIPO: .NET, VERSIONE ECC. C'è anche la directory delle rispettive dll. Sono questi che mi impicciano???
Se li rimuovo dalla lista non mi funziona più il programma?
Ho provato a copiarli nel pc di destinazione ma il prog non parte lo stesso... non funzia neanche con la pubblicazione guidata di VS
Grazie 1000 x la tua risposta :)
Questo messaggio è stato aggiornato da markokr83 il 10/09/2007 alle ore 17:33:47
Allora hai usato visual basic per creare la tua applicazione?
si visual basic. Perfavore rileggi sopra che ho editato il messaggio.... Grazie
Hey mi devi dire che problemi hai avuto sulla macchina,
ti darà un'errore.. insomma qualcosa?
"Applicazione non correttamente inizializzata (0000035)"
Facendo ricerche su internet scopro che è il framework 2.0, infatti installandolo sulla macchina poi il prog va che è una bellezza...
Dall'altro pc hai portato solo l'eseguibile giusto?
Se vuoi posta pure il codice, ci diamo un'occhiata.
Questo messaggio è stato aggiornato da marcoff il 10/09/2007 alle ore 17:45:14
Prova cosi....
http://www.visual-basic.it/articoli/adsVsi.htm
Fammi sapere se funziona.;)
si l'eseguibile con il file esterni necessari... ti posto il codice, sei molto gentile
PS, ho provato a rimuovere quelle voci e ho fatto casino
Public Class fmrmain
Dim Pulsante, Pulsante1, Abilitato, conteggio, start, i, Indice1 As Integer
Dim livello, punteggio, stato As Integer
Dim stringa As String
Private mouseOffset As Drawing.Point
Private isMouseDown As Boolean = False
Dim s() As String
Dim nomefile As String
Private Sub lblbtn1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles btn1.MouseDown
If Abilitato = 0 Then
GoTo fine
End If
btn1.ImageIndex = 3
fine:
End Sub
Private Sub lblbtn1_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles btn1.MouseUp
If Abilitato = 0 Then
GoTo fine
End If
btn1.ImageIndex = 2
Pulsante1 = "1"
btngiudice.PerformClick()
fine:
End Sub
Private Sub lblbtn3_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles btn3.MouseDown
If Abilitato = 0 Then
GoTo fine
End If
btn3.ImageIndex = 3
fine:
End Sub
Private Sub lblbtn3_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles btn3.MouseUp
If Abilitato = 0 Then
GoTo fine
End If
btn3.ImageIndex = 2
Pulsante1 = "3"
btngiudice.PerformClick()
fine:
End Sub
Private Sub btnstart_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnstart.Click
'faccio partire il tempo
lbltime.Text = 20
lbltime.ImageIndex = 0
lbltime.Visible = True
tmrtempo.Enabled = True
'disabilito pulsante start
start = 0
' Tmrlamp.Enabled = False
'pulisco la lista, pulsanti e text
lblschermo.Text = "
List2.Items.Clear()
btn1.Text = "
btn2.Text = "
btn3.Text = "
btn4.Text = "
'randomizzo la domanda
Dim IndiceN As Integer
IndiceN = List1.Items.Count
Randomize()
Dim Indice As Integer = CInt(Int(IndiceN * Rnd()))
Indice1 = Indice
List1.SelectedIndex = Indice
'sposto la domanda scelta nella seconda lista
i = 0
stringa = List1.SelectedItem
s = Split(stringa, "#" ;)
For i = 0 To UBound(s)
List2.Items.Add(s(i))
Next
'la distribuisco nel form
'domanda
List2.SelectedIndex = 0
lblschermo.Text = List2.SelectedItem
'pulsanti. in base al numero random uscito colloco la domanda esatta in uno
'dei quattro pulsanti e poi distribuisco il resto
Pulsante = CInt(Int(4 * Rnd()) + 1)
' la variabile pulsante è dhichiarata sopra
If Pulsante = "1" Then
List2.SelectedIndex = 1
btn1.Text = List2.SelectedItem
List2.SelectedIndex = 2
btn2.Text = List2.SelectedItem
List2.SelectedIndex = 3
btn3.Text = List2.SelectedItem
List2.SelectedIndex = 4
btn4.Text = List2.SelectedItem
End If
If Pulsante = "2" Then
List2.SelectedIndex = 1
btn2.Text = List2.SelectedItem
List2.SelectedIndex = 2
btn1.Text = List2.SelectedItem
List2.SelectedIndex = 3
btn3.Text = List2.SelectedItem
List2.SelectedIndex = 4
btn4.Text = List2.SelectedItem
End If
If Pulsante = "3" Then
List2.SelectedIndex = 1
btn3.Text = List2.SelectedItem
List2.SelectedIndex = 2
btn2.Text = List2.SelectedItem
List2.SelectedIndex = 3
btn1.Text = List2.SelectedItem
List2.SelectedIndex = 4
btn4.Text = List2.SelectedItem
End If
If Pulsante = "4" Then
List2.SelectedIndex = 1
btn4.Text = List2.SelectedItem
List2.SelectedIndex = 2
btn2.Text = List2.SelectedItem
List2.SelectedIndex = 3
btn3.Text = List2.SelectedItem
List2.SelectedIndex = 4
btn1.Text = List2.SelectedItem
End If
'abilito i pulsanti
Abilitato = 1
fine:
End Sub
Private Sub lblbtn2_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles btn2.MouseDown
If Abilitato = 0 Then
GoTo fine
End If
btn2.ImageIndex = 1
fine:
End Sub
Private Sub lblbtn2_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles btn2.MouseUp
If Abilitato = 0 Then
GoTo fine
End If
btn2.ImageIndex = 0
Pulsante1 = "2"
btngiudice.PerformClick()
fine:
End Sub
Private Sub lblbtn4_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles btn4.MouseDown
If Abilitato = 0 Then
GoTo fine
End If
btn4.ImageIndex = 1
fine:
End Sub
Private Sub lblbtn4_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles btn4.MouseUp
If Abilitato = 0 Then
GoTo fine
End If
btn4.ImageIndex = 0
Pulsante1 = "4"
btngiudice.PerformClick()
fine:
End Sub
Private Sub fmrmain_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'abilito pulsante start
start = 1
'preparo variabili livello e punteggio
livello = 0
punteggio = 0
'setto label del tempo
lbltime.Text = 20
lbltime.Visible = False
'inserisco il nome del primo file all'avvio del programma
nomefile = "\dl1.dat"
End Sub
Private Sub btngiudice_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btngiudice.Click
'fermo il tempo
tmrtempo.Enabled = False
'controlla se la risposta è esatta
If Pulsante = Pulsante1 Then
punteggio = punteggio + (5 * lbltime.Text)
livello = livello + 1
lblschermo.Text = "La risposta è esatta!!!" & vbCrLf & vbCrLf & "Livello: " & livello & vbCrLf & "Punteggio: " & punteggio
Abilitato = 0
conteggio = 0
'rimuove la domanda selezionata in modo che non la ripete
' List1.Items.Remove(Indice1)
List1.SelectedIndex = Indice1
List1.Items.Remove(List1.SelectedItem)
'CONTROLLO IL LIVELLO E SE ARRIVA ALLA SOGLIA CAMBIO LISTA DELLE DOMANDE
'CON IL CARICABTN
'cambiando i valori posso determinare quante domande di ciascun livello spettano
If livello = 0 Then
nomefile = "\dl1.dat"
caricabtn.PerformClick()
End If
If livello = 6 Then
nomefile = "\dl2.dat"
caricabtn.PerformClick()
End If
If livello = 13 Then
nomefile = "\dl3.dat"
caricabtn.PerformClick()
End If
Else
List2.SelectedIndex = 1
lblschermo.Text = "La risposta esatta era: " & List2.SelectedItem & vbCrLf & "Livello: " & livello & " , Punteggio: " & punteggio & vbCrLf & vbCrLf & "Premi Start per ricominciare"
'resetto livello e punti
livello = 0
punteggio = 0
'resetto i pulsanti
Abilitato = 0
conteggio = 0
End If
'se è sbagliata accendo il pulsante rosso
If Pulsante <> Pulsante1 Then
If Pulsante1 = 1 Then
btn1.ImageIndex = 7
End If
If Pulsante1 = 2 Then
btn2.ImageIndex = 6
End If
If Pulsante1 = 3 Then
btn3.ImageIndex = 7
End If
If Pulsante1 = 4 Then
btn4.ImageIndex = 6
End If
End If
'abilito timer lampeggio
Tmrlamp.Enabled = True
End Sub
Private Sub Tmrlamp_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Tmrlamp.Tick
conteggio = conteggio + 1
Label1.Text = conteggio
'ricoloro i pulsanti di bianco
btn1.ForeColor = Drawing.Color.White
btn2.ForeColor = Drawing.Color.White
btn3.ForeColor = Drawing.Color.White
btn4.ForeColor = Drawing.Color.White
'codice per il lampeggio del pulsante
'pulsante numero 1
If Pulsante = 1 Then
If btn1.ImageIndex = 2 Then
btn1.ImageIndex = 5
Else
btn1.ImageIndex = 2
End If
End If
'pulsante numero 3
If Pulsante = 3 Then
If btn3.ImageIndex = 2 Then
btn3.ImageIndex = 5
Else
btn3.ImageIndex = 2
End If
End If
'pulsante numero 2
If Pulsante = 2 Then
If btn2.ImageIndex = 0 Then
btn2.ImageIndex = 4
Else
btn2.ImageIndex = 0
End If
End If
'pulsante numero 4
If Pulsante = 4 Then
If btn4.ImageIndex = 0 Then
btn4.ImageIndex = 4
Else
btn4.ImageIndex = 0
End If
End If
'----------------
If conteggio = 8 Then
Tmrlamp.Enabled = False
btn1.ImageIndex = 2
btn2.ImageIndex = 0
btn3.ImageIndex = 2
btn4.ImageIndex = 0
'////////////QUANDO ARRIVA A 20 COMPLETA IL GIOCO. AUMENTARE IL VALORE
'SE SI VOGLIONO + LIVELLI
If livello = 20 Then
lblschermo.Text = "Complimenti!!!" & vbCrLf & vbCrLf & "Hai completato tutti i livelli del quiz!!!" & vbCrLf & "Livello: 20 - " & "Punteggio: " & punteggio
start = 1
Abilitato = 0
livello = 0
btn1.Text = "Quiz"
btn2.Text = "Quiz"
btn3.Text = "Quiz"
btn4.Text = "Quiz"
nomefile = "\dl1.dat"
caricabtn.PerformClick()
GoTo fine
End If
' se è giusta vado con la prossima
If Pulsante = Pulsante1 Then
btnstart.PerformClick()
Else 'se sbagliata riattivo il pulsante start
start = 1
caricabtn.PerformClick()
End If
End If
fine:
End Sub
Private Sub lblstart_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles lblstart.MouseDown
If start = 0 Then
GoTo fine
End If
lblstart.ImageIndex = 1
fine:
End Sub
Private Sub lblstart_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles lblstart.MouseUp
If start = 0 Then
GoTo fine
End If
'ricarico la lista con il button carica
List1.Items.Clear()
caricabtn.PerformClick()
'comincio il gioco
lblstart.ImageIndex = 0
btnstart.PerformClick()
fine:
End Sub
Private Sub btn1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles btn1.MouseMove
'INIZIO CODICE PER EVIDENZIARE PULSANTE AL PASSAGGIO DEL MOUSE
'/////////////////////////////////////////////////////////////
If Abilitato = 0 Then
GoTo fine
End If
btn1.ForeColor = Drawing.Color.Yellow
fine:
End Sub
Private Sub btn1_MouseLeave(ByVal sender As Object, ByVal e As System.EventArgs) Handles btn1.MouseLeave
btn1.ForeColor = Drawing.Color.White
End Sub
Private Sub btn2_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles btn2.MouseMove
If Abilitato = 0 Then
GoTo fine
End If
btn2.ForeColor = Drawing.Color.Yellow
fine:
End Sub
Private Sub btn2_MouseLeave(ByVal sender As Object, ByVal e As System.EventArgs) Handles btn2.MouseLeave
btn2.ForeColor = Drawing.Color.White
End Sub
Private Sub btn3_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles btn3.MouseMove
If Abilitato = 0 Then
GoTo fine
End If
btn3.ForeColor = Drawing.Color.Yellow
fine:
End Sub
Private Sub btn3_MouseLeave(ByVal sender As Object, ByVal e As System.EventArgs) Handles btn3.MouseLeave
btn3.ForeColor = Drawing.Color.White
End Sub
Private Sub btn4_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles btn4.MouseMove
If Abilitato = 0 Then
GoTo fine
End If
btn4.ForeColor = Drawing.Color.Yellow
fine:
End Sub
Private Sub btn4_MouseLeave(ByVal sender As Object, ByVal e As System.EventArgs) Handles btn4.MouseLeave
btn4.ForeColor = Drawing.Color.White
'FINE CODICE PER EVIDENZIARE PULSANTI AL PASSAGGIO DEL MOUSE
'////////////////////////////////////////////////////////////
End Sub
Private Sub caricabtn_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles caricabtn.Click
'il codice sottostante carica il file di testo delle domande e lo inserisce nella prima lista
Dim reader As IO.StreamReader = New IO.StreamReader(My.Application.Info.DirectoryPath & nomefile)
Try
Me.List1.Items.Clear()
Do
Me.List1.Items.Add(reader.ReadLine)
Loop Until reader.Peek = -1
Catch
Me.List1.Items.Add("File is empty" ;)
Finally
reader.Close()
End Try
End Sub
Private Sub tmrpunti_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles tmrtempo.Tick
lbltime.Text = lbltime.Text - 1
If lbltime.Text = 15 Then
lbltime.ImageIndex = 1
End If
If lbltime.Text = 10 Then
lbltime.ImageIndex = 2
End If
If lbltime.Text = 5 Then
lbltime.ImageIndex = 3
End If
If lbltime.Text = 0 Then
lbltime.ImageIndex = 4
tmrtempo.Enabled = False
End If
End Sub
Private Sub lblchiudi_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles lblchiudi.MouseDown
lblchiudi.ImageIndex = 1
End Sub
Private Sub lblchiudi_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles lblchiudi.MouseUp
lblchiudi.ImageIndex = 0
End
End Sub
Private Sub lblriduci_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles lblriduci.MouseDown
lblriduci.ImageIndex = 3
End Sub
Private Sub lblriduci_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles lblriduci.MouseUp
lblriduci.ImageIndex = 2
Me.WindowState = Windows.Forms.FormWindowState.Minimized
End Sub
Private Sub lblinfo_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles lblinfo.MouseDown
If Tmrlamp.Enabled = True Then
GoTo fine
End If
lblinfo.ImageIndex = 5
fine:
End Sub
Private Sub lblinfo_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles lblinfo.MouseUp
If Tmrlamp.Enabled = True Then
GoTo fine1
End If
'visualizzo le informazioni e disabilito i tasti
lblinfo.ImageIndex = 4
lblring.Visible = True
btnesci.Visible = True
lblschermo.Visible = False
'disabilito i tasti
'memorizzo lo stato del gioco per poi ripristinarlo uscendo dalle info
If start = 1 Then
stato = 0
GoTo fine
Else
stato = 1
GoTo fine
End If
fine:
start = 0
Abilitato = 0
fine1:
End Sub
Private Sub btnesci_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnesci.Click
lblring.Visible = False
btnesci.Visible = False
lblschermo.Visible = True
If stato = 0 Then
start = 1
Abilitato = 0
End If
If stato = 1 Then
start = 0
Abilitato = 1
End If
End Sub
Private Sub fmrmain_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseDown
'il seguente codice serve a far muovere il form
'/////////da qua/////////////////////////////
Dim xOffset As Integer
Dim yOffset As Integer
If e.Button = Windows.Forms.MouseButtons.Left Then
xOffset = -e.X - SystemInformation.FrameBorderSize.Width
yOffset = -e.Y - SystemInformation.CaptionHeight - _
SystemInformation.FrameBorderSize.Height
mouseOffset = New Drawing.Point(xOffset, yOffset)
isMouseDown = True
End If
End Sub
Private Sub fmrmain_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseMove
If isMouseDown Then
Dim mousePos As Drawing.Point = Control.MousePosition
mousePos.Offset(mouseOffset.X, mouseOffset.Y)
Location = mousePos
End If
End Sub
Private Sub fmrmain_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseUp
If e.Button = Windows.Forms.MouseButtons.Left Then
isMouseDown = False
End If
'///////A QUA//////////////////
End Sub
End Class
Windows.Forms.MouseButtons.Left
Drawing.Point
Per esempio queste librerie, dove sono contenuti i metodi che tu hai referenziato, cioè per esempio
Windows.Forms.MouseButtons.Left
Drawing.Point
non sono incluse nelle librerie del Os.
Pertanto dovresti includerle in un pacchetto di installazione.
Prova con il procedimento che ti ho postato e fammi sapere.
ok capito, quindi, o rimuovo i riferimenti oppure le includo in un pacchetto di installazione...
l'ultima domanda, queste librerie, in che cartella vanno??? system32???
Grazie ancora x la tua gentilezza
non so precisamente dove devi metterle,
ma dovrebbe farlo in automatico il pacchetto quando installi.
ok + tardi faccio una prova, poi posto. Grazie davvero x il tuo interessamento. Ciao
Di niente.