26 May '13 - 04:53 *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
 
  Home Help Search Login Register  
  Show Posts
Pages: [1]
1  Developments / BASS / Re: [VB.NET] Forcefully unload and remove dll on application exit on: 17 Jan '10 - 01:40
    <DllImport("kernel32.dll", CharSet:=CharSet.Auto, SetLastError:=True)> _
    Public Shared Function LoadLibrary(<[In](), MarshalAs(UnmanagedType.LPStr)> ByVal lpFileName As String) As IntPtr
    End Function
    <DllImport("kernel32.dll", CharSet:=CharSet.Auto, SetLastError:=True)> _
    Public Shared Function GetModuleHandle(ByVal lpModuleName As String) As IntPtr
    End Function
    <DllImport("kernel32.dll", CharSet:=CharSet.Auto, SetLastError:=True)> _
    Public Shared Function FreeLibrary(<[In]()> ByVal hModule As IntPtr) As Boolean
    End Function

'==============================

        BASSMOD_MusicStop()
        BASSMOD_Free() 'don't know if this is still needed since I'm doing it myself
        Dim hAddress As Long = GetModuleHandle("bassmod.dll")
        While hAddress >= 1
            FreeLibrary(hAddress)
            hAddress = GetModuleHandle("bassmod.dll")
        End While
        File.Delete("bassmod.dll")

Have to loop it for some reason, as just one call doesn't seem to take care of it.

Minimal overhead, but it works. Smiley
ReplyReply Reply with quoteQuote
2  Developments / BASS / Re: [VB.NET] Forcefully unload and remove dll on application exit on: 16 Jan '10 - 11:42
.Net typically does NOT unload any dynamically loaded assembly until you exit your app.

Any way to force it to unload the the dll and delete any references?
ReplyReply Reply with quoteQuote
3  Developments / BASS / [VB.NET] Forcefully unload and remove dll on application exit on: 16 Jan '10 - 07:45
    <System.Runtime.InteropServices.DllImport("bassmod.dll", CharSet:=CharSet.Auto)> _
    Public Shared Function BASSMOD_Free() As <MarshalAs(UnmanagedType.Bool)> Boolean
    End Function

I'm importing and calling the function, but even after Free'ing the library, I still can't manage to delete it.

Any ideas?
ReplyReply Reply with quoteQuote
4  Developments / BASS / Re: Managed port possible? on: 26 Oct '09 - 16:16
'e' that you mentioned above I'm unaware of.

I've yet to find a way to bundle unmanaged libraries within an .exe.
ReplyReply Reply with quoteQuote
5  Developments / BASS / Managed port possible? on: 26 Oct '09 - 07:38
I'm wondering if a managed port will ever be made so we .NET devs can actually bundle the .dll into our application.

I'm aware of BASS.NET, but the two DLL thing and extra inflation to the distribution is a pretty hefty drawback when you're aiming for single-file releases.
ReplyReply Reply with quoteQuote
6  Developments / BASS / Re: VB.NET: BassMOD.NET as EmbeddedResource (Working) on: 4 Aug '09 - 18:14
Ok, my bad, didn't notice that there was more than one method for loading.

Have it reading from a byte stream now.  Thanks.

        st = as1.GetManifestResourceStream("App_NameSpace.2.mod")
        Dim modFile As Byte() = New Byte(st.Length) {}
        st.Read(block, 0, block.Length)
        st.Dispose()
        bass.BASSMOD_Init(-1, 44100, 0)
        bass.BASSMOD_MusicLoad(block, 0, block.Length(), mFlags.BASS_MUSIC_LOOP)
        bass.BASSMOD_MusicPlay()
ReplyReply Reply with quoteQuote
7  Developments / BASS / Re: VB.NET: BassMOD.NET as EmbeddedResource on: 4 Aug '09 - 17:49
I have the .net wrapper loading from an embedded resource properly, was hoping there was a way I wouldn't have to distribute more than the one file, if at all possible.

Also, how, using the .net wrapper, can I feed bassmod.net a .mod file as a string/bytearray/memorystream?
ReplyReply Reply with quoteQuote
8  Developments / BASS / Re: VB.NET: BassMOD.NET as EmbeddedResource on: 4 Aug '09 - 00:53
Using BassMOD.Net.dll still requires BASSMOD.dll, how can I package BASSMOD.dll as an EmbeddedResource alongside BassMOD.Net.dll?
ReplyReply Reply with quoteQuote
9  Developments / BASS / VB.NET: BassMOD.NET as EmbeddedResource (Working) on: 4 Aug '09 - 00:37
BassMOD.Net as an EmbeddedResource, loading the .dll from a MemoryStream.

       Dim as1 As Assembly = Assembly.GetEntryAssembly()
        Dim st As UnmanagedMemoryStream = as1.GetManifestResourceStream("Your_NameSpace.BassMOD.Net.dll")
        Dim block As Byte() = New Byte(st.Length) {}
        st.Read(block, 0, block.Length)
        Dim as2 As Assembly = Assembly.Load(block)

        bass = as2.CreateInstance("Un4seen.BassMOD.BassMOD", _
                    False, _
                    System.Reflection.BindingFlags.Public Or _
                    System.Reflection.BindingFlags.Instance Or _
                    System.Reflection.BindingFlags.InvokeMethod, _
                    Nothing, _
                    Nothing, _
                    Nothing, _
                    Nothing)
        Dim mFlags = as2.CreateInstance("Un4seen.BassMOD.BASSMusic", _
                    False, _
                    System.Reflection.BindingFlags.Public Or _
                    System.Reflection.BindingFlags.Instance Or _
                    System.Reflection.BindingFlags.InvokeMethod, _
                    Nothing, _
                    Nothing, _
                    Nothing, _
                    Nothing)

The above code works, and I'm leaving it pasted as an example to anyone else that wants to use BassMOD.Net from an EmbeddedResource.  Simply add the .dll as a resource (not a reference) and set it's compile option to "EmbeddedResource", add this code in Me.Load / MyBase.Load and you're done.  Cheesy

To play a .mod file using the above method (the reason for two-instances), use the code below.

       bass.BASSMOD_Init(-1, 44100, 0)
        bass.BASSMOD_MusicLoad("Full Path to MOD File", 0, 0, mFlags.BASS_MUSIC_LOOP)
        bass.BASSMOD_MusicPlay()
ReplyReply Reply with quoteQuote
Pages: [1]
Powered by SMF 1.1.18 | SMF © 2013, Simple Machines