system.outofmemory exception, music problem

i have music resources and it seems i keep getting system.outofmemory exception. here is my code, and if you could figure out why exactly im getting this exception. im thinking it has to do with my music resources, and i checked the songs they work fine.

Public Class WWE

Friend WithEvents mediasoundplayer As New System.Media.SoundPlayer

Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged

ComboBox2.Show()

End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click

Dim answer As MsgBoxResult

answer = MsgBox("Are you sure you want to exit ", MsgBoxStyle.YesNo)

If answer = MsgBoxResult.Yes Then

End

End If

End Sub

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Try

Select Case ComboBox1.SelectedItem

Case Is = ComboBox1.Text

MessageBox.Show("Your favorite show: " & ComboBox1.Text())

End Select

Select Case ComboBox2.SelectedItem

Case Is = ComboBox2.Text

MessageBox.Show("Your favorite superstar: " & ComboBox2.Text())

End Select

Catch ex As Exception

MessageBox.Show("You did not select a show or superstar.", "Selecting Problem", MessageBoxButtons.OK, MessageBoxIcon.Error)

End Try

End Sub

Private Sub WWE_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load

mediasoundplayer.Stream = My.Resources.Three_Days_Grace___Riot

mediasoundplayer.PlayLooping()

Dim wwesite As String = "http://www.wwe.com"

Me.LinkLabel1.Links.Add(0, wwesite.Length, wwesite)

Me.LinkLabel1.Text = "WWE SITE"

End Sub

Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles aboutbutton.Click

Hide()

AboutBox1.Show()

End Sub

Private Sub TextBox1_TextChanged_1(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged

If My.Computer.FileSystem.FileExists(TextBox1.Text) Then

MsgBox("File Found")

Else

MsgBox("File not Found")

End If

End Sub

Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged

Try

Select Case ListBox1.SelectedItem

Case Is = "Static X - Start A War"

mediasoundplayer.Stream = My.Resources.Static_X___Start_A_War

mediasoundplayer.PlayLooping()

End Select

Catch ex As System.OutOfMemoryException

MessageBox.Show("You dont have enough memory to run this program.", "Memory Problem", MessageBoxButtons.OK, MessageBoxIcon.Error)

End Try

End Sub

Private Sub LinkLabel1_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles LinkLabel1.LinkClicked

e.Link.Visited = True

System.Diagnostics.Process.Start(e.Link.LinkData.ToString())

End Sub

End Class




Answer this question

system.outofmemory exception, music problem

  • Dagz

    mcgin1591,

    How is your project going There is an article contains prooject example on Using CopyMemory in .NET of the code project website and I hope it will help you to solve your public sharing problem with your friends. The link is as folllows:

    http://www.codeproject.com/vb/net/netcopymemorysample.asp



  • doctorx0079

    anyone know how i can exactly get this for sending it to friends. like the media player how to get it for friends, since i dont know exactly what to do for the folder parts and stuff. if you have an idea of what im talking about please post!

  • tattoo

    You are probably right, .wav files are uncompressed and can get very large. When added as a resource, you pay for the size twice. You might fix it by enlarging the size of your paging file. But it's a better if you just keep it as a file on disk, played by Windows Media Player...


  • Jonas Beckeman

    tried that, and i know how to do it, but i want to publish to my friends. and the problem is i dont understand how they can play it if its already located in my documents....i mean i dont know how to get it so they can play it without having to change it themselfs or anything.

  • system.outofmemory exception, music problem