3 Replies - 811 Views - Last Post: 04 November 2013 - 05:25 PM Rate Topic: -----

#1 VBAConvert  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 15
  • Joined: 23-June 13

Deploying a MySql VB.net application on local host developer machine

Posted 03 November 2013 - 06:15 AM

I am working in the visual studio express 2012 for windows desktop. I have a fresh installation of MySQL 5.6.14 community server on a my Win64 localhost laptop. I am coming from the vba environment deploying a solution and working with a real DB vice Access is new to me. However, I have the following code.

Imports MySql.Data.MySqlClient
Public Class Form1




    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Dim mysqlcnnt As New MySqlConnection("server=localhost; user id=root; password=InternetSub; database=sakila")
        Dim query As String
        Dim adapter As New MySqlDataAdapter()
        Dim datset As New DataTable
        Dim lpcnt As Integer
        Dim lplmt As Integer

        lpcnt = 0
        query = "select * from actor;"
        adapter.SelectCommand = New MySqlCommand(query, mysqlcnnt)
        adapter.Fill(datset)
        lplmt = datset.Rows.Count
        Do While lpcnt < lplmt
            txtActor.Text = datset.Rows(lpcnt).Item("last_name")
            txtActor.Update()
            System.Threading.Thread.Sleep(5)
            lpcnt = lpcnt + 1
            If (lpcnt Mod 15) = 0 Then
                PictureBox1.Image = Image.FromFile("c:\vbimage\" & CStr(lpcnt Mod 2) & ".jpg")
                PictureBox1.Update()
            End If

        Loop

        txtActor.Text = Application.ExecutablePath()
        Label1.Text = Environment.ProcessorCount
        'Label1.Update()

        ' MsgBox("something")
    End Sub
End Class

So like a million newbies and hack developers before me. When I run this as a debug in the IDE is works like I expected it to. When I run the deployed solution it gives me the following error. "Unhandled exception has occurred in your application. If you click Continue, the application will ignore this error and attempt to continue. If you click quit, the application will close immediately. Could not load file or assembly 'MySql.Data.CF.Version=6.7.4.0. Culture=neutral, , PublicKeyToken=c5687fc88969c44d, Retargetable=Yes' or one of its dependencies. The given assembly name or codebase was invalid. (exception from HRESULT: 0x80131047)."

For the most part this is a fresh install of both vb.net and mysql. Following references added MySql.Data.CF

Seems like i am doing some really basic stuff so the answer is likely one that has been solved a hundred times over so thanks for putting up with my ignorance.



The code of the referenced form is
<Global.Microsoft.VisualBasic.CompilerServices.DesignerGenerated()> _
Partial Class Form1
    Inherits System.Windows.Forms.Form

    'Form overrides dispose to clean up the component list.
    <System.Diagnostics.DebuggerNonUserCode()> _
    Protected Overrides Sub Dispose(ByVal disposing As Boolean)
        Try
            If disposing AndAlso components IsNot Nothing Then
                components.Dispose()
            End If
        Finally
            MyBase.Dispose(disposing)
        End Try
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    <System.Diagnostics.DebuggerStepThrough()> _
    Private Sub InitializeComponent()
        Dim resources As System.ComponentModel.ComponentResourceManager = New System.ComponentModel.ComponentResourceManager(GetType(Form1))
        Me.txtActor = New System.Windows.Forms.TextBox()
        Me.Label1 = New System.Windows.Forms.Label()
        Me.Button1 = New System.Windows.Forms.Button()
        Me.PictureBox1 = New System.Windows.Forms.PictureBox()
        CType(Me.PictureBox1, System.ComponentModel.ISupportInitialize).BeginInit()
        Me.SuspendLayout()
        '
        'txtActor
        '
        Me.txtActor.Location = New System.Drawing.Point(58, 36)
        Me.txtActor.Name = "txtActor"
        Me.txtActor.Size = New System.Drawing.Size(173, 20)
        Me.txtActor.TabIndex = 0
        '
        'Label1
        '
        Me.Label1.AutoSize = True
        Me.Label1.Location = New System.Drawing.Point(60, 73)
        Me.Label1.Name = "Label1"
        Me.Label1.Size = New System.Drawing.Size(39, 13)
        Me.Label1.TabIndex = 1
        Me.Label1.Text = "Label1"
        '
        'Button1
        '
        Me.Button1.Location = New System.Drawing.Point(138, 78)
        Me.Button1.Name = "Button1"
        Me.Button1.Size = New System.Drawing.Size(92, 31)
        Me.Button1.TabIndex = 2
        Me.Button1.Text = "Button1"
        Me.Button1.UseVisualStyleBackColor = True
        '
        'PictureBox1
        '
        Me.PictureBox1.Image = CType(resources.GetObject("PictureBox1.Image"), System.Drawing.Image)
        Me.PictureBox1.Location = New System.Drawing.Point(17, 142)
        Me.PictureBox1.Name = "PictureBox1"
        Me.PictureBox1.Size = New System.Drawing.Size(112, 118)
        Me.PictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.StretchImage
        Me.PictureBox1.TabIndex = 3
        Me.PictureBox1.TabStop = False
        '
        'Form1
        '
        Me.AutoScaleDimensions = New System.Drawing.SizeF(6.0!, 13.0!)
        Me.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font
        Me.AutoSize = True
        Me.ClientSize = New System.Drawing.Size(384, 361)
        Me.Controls.Add(Me.PictureBox1)
        Me.Controls.Add(Me.Button1)
        Me.Controls.Add(Me.Label1)
        Me.Controls.Add(Me.txtActor)
        Me.Name = "Form1"
        Me.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen
        Me.Text = "SPECIAL NAME"
        CType(Me.PictureBox1, System.ComponentModel.ISupportInitialize).EndInit()
        Me.ResumeLayout(False)
        Me.PerformLayout()

    End Sub
    Friend WithEvents txtActor As System.Windows.Forms.TextBox
    Friend WithEvents Label1 As System.Windows.Forms.Label
    Friend WithEvents Button1 As System.Windows.Forms.Button
    Friend WithEvents PictureBox1 As System.Windows.Forms.PictureBox

End Class


Is This A Good Question/Topic? 0
  • +

Replies To: Deploying a MySql VB.net application on local host developer machine

#2 astonecipher  Icon User is offline

  • Major DIC Head
  • member icon

Reputation: 732
  • View blog
  • Posts: 3,179
  • Joined: 03-December 12

Re: Deploying a MySql VB.net application on local host developer machine

Posted 03 November 2013 - 06:38 PM

First, you deployed an application without Error Handling?

You deployed the application, did you include the database with your deployment package?
Was This Post Helpful? 0
  • +
  • -

#3 jimzcoder  Icon User is offline

  • D.I.C Regular

Reputation: 54
  • View blog
  • Posts: 335
  • Joined: 14-November 12

Re: Deploying a MySql VB.net application on local host developer machine

Posted 03 November 2013 - 06:55 PM

if you already did what astonecipher asked.
then have you tried running the deployed application in an elevated privilege?
i have encountered some sort of error before and running the program as administrator just did the trick.

Hope it helped.
Good Luck.
Was This Post Helpful? 0
  • +
  • -

#4 VBAConvert  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 15
  • Joined: 23-June 13

Re: Deploying a MySql VB.net application on local host developer machine

Posted 04 November 2013 - 05:25 PM

Guys/Gals? DICs Thanks for joining the conversation. Solution and follow-on question after responses
Astonecipher:
I was a little careless in my phrasing. By deploy, I meant publish the executable through the build menu to try it outside of the IDE environment. So this code block is really a learning exercise but that said I will put a note in my nub book to not mix deploy and unfinished code in the same discussion. As to deploying the database. Great concept, one that I am sure I will spend a lot of time thinking about as I do not know how I would deploy the backend MySQL database through the >Build>>Publish menu although I can think of imbedding the SQL statement that will build the schema. However in this case I believe that I was failing to establish the MySQL server connection in the Published format and that method of "deploying the database would not work". Back to the heart of the statement, installed the published build on the developer machine without modification of the local host server so the code was still pointing to the same local host server.
jimzcoder:
Thanks, I am at the administrator level on the Windows privileges and accessing the database at the root so those issues were covered.

So, without any good reason for doing so I removed the MySql.Data.CF from the Project>Add Reference>>Extensions and replaced it with MySQL.DATA. I believe that I picked the MySql.Data.CF off of a youtube video and now have selected the other for the same reason. In any case, the published exe performs as the debug did. Hurray.
Unfortunately my understanding of the difference did not really improve and there is an additional issue. In my Reference Manager Targeting: .NET I have multiple entries of the same extensions. Specifically, I have three separate entries of MySql.Data. Weird right?
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1