Author Topic: [VB.NET]Conversion from string "" to type 'Long' is not valid.  (Read 3320 times)

Cai Lee

  • Guest
hi everyone, i have a question with bassmidi,why im using BASS_SetConfigPtr it gives the error shows Conversion from string "" to type 'Long' is not valid.
but in example the 2 argurments should be char *filename, why it says it's long???
please Help me
Thanks

Code: [Select]
Imports Un4seen.Bass
Imports Un4seen.Bass.BASSConfig
Imports Un4seen.Bass.AddOn.Midi.BassMidi






Public Class Form1

    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Bass.BASS_PluginLoad("bassmidi.dll")


    End Sub

    Private Sub PLAY_Click(sender As Object, e As EventArgs) Handles PLAY.Click
        OpenFileDialog1.ShowDialog()



        Bass.BASS_SetConfigPtr(BASS_CONFIG_MIDI_DEFFONT, "C:/test.sf2")

        Dim streamy As Integer

        streamy = Bass.BASS_StreamCreateFile(OpenFileDialog1.FileName, 0L, 0L, BASSFlag.BASS_DEFAULT)
        Bass.BASS_ChannelPlay(streamy, True)
        Me.Text = OpenFileDialog1.FileName



    End Sub

    Private Sub OpenFileDialog2_FileOk(sender As Object, e As System.ComponentModel.CancelEventArgs)



    End Sub

Ian @ un4seen

  • Administrator
  • Posts: 20401
I'm not a .Net user myself, so I'm not certain about this, but I think you may need to "Marshal" the string. Please see the BASS_SetConfigPtr page in the BASS.Net documentation for some example snippets.

radio42

  • Posts: 4574
When dealing with config strings the "BASS_SetConfigPtr" is actually the correct overload.
But as the name and signature suggests, it takes an IntPtr as an argument and not a string directly - see the docs for details!

Here is an example (taken from the docs) on how to use it:
Code: [Select]
IntPtr myStrPtr = Marshal.StringToHGlobalAnsi("C:/test.sf2");
Bass.BASS_SetConfigPtr(BASSConfig.BASS_CONFIG_MIDI_DEFFONT, myStrPtr);
Marshal.FreeHGlobal(myStrPtr);

Code: [Select]
Dim myStrPtr As IntPtr = Marshal.StringToHGlobalAnsi("C:/test.sf2")
Bass.BASS_SetConfigPtr(BASSConfig.BASS_CONFIG_MIDI_DEFFONT, myStrPtr)
Marshal.FreeHGlobal(myStrPtr)