18 May '13 - 12:43 *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
 
   Home   Help Search Login Register  
Pages: [1]
  Reply  |  Print  
Author Topic: Never used a library before....  (Read 1187 times)
Cody
Guest
« on: 6 Dec '11 - 03:13 »
Reply with quoteQuote

I'm fairly new to all of this, but especially with using libraries. I'm slowly learning from others' posts, but there is one problem I keep having. Whenever I try to do anything C# keeps telling me that Bass has thrown an exception. What am I missing, and where do I need to put it?
Logged
radio42
Posts: 4012


« Reply #1 on: 6 Dec '11 - 08:17 »
Reply with quoteQuote

What exact exception do you get?
Can you also post the code you are using to take a look at?
Have you also taken a look to the Bass.Net documentation and the sample to compare what might be 'wrong'?
Maybe you are running into one of the following issues:
a) the native bass.dll is missing in your executable directory (e.g. .\bin\Debug)?
b) you are compiling your app as for 'Any CPU' on a x64 OS and thus need to use the native x64 bass.dll?
Logged
Cody
Guest
« Reply #2 on: 6 Dec '11 - 18:19 »
Reply with quoteQuote

Do I need the regular bass.dll if I'm using bass.net.dll?
Logged
Cody
Guest
« Reply #3 on: 6 Dec '11 - 18:50 »
Reply with quoteQuote

Also here's my code.

openFileDialog1.ShowDialog();
            TAG_INFO bssSongInfo = BassTags.BASS_TAG_GetFromFile(openFileDialog1.FileName);

            lblInfo.Text = bssSongInfo.artist;
Logged
radio42
Posts: 4012


« Reply #4 on: 6 Dec '11 - 22:27 »
Reply with quoteQuote

Quote
Do I need the regular bass.dll if I'm using bass.net.dll?
Yes - as explained in the exensive documentation - didn't you read that?
Logged
Cody
Guest
« Reply #5 on: 7 Dec '11 - 23:36 »
Reply with quoteQuote

Alright, I went over the documentation. Still not sure how to implement bass.dll into code. Is it really that difficult for you to just tell me what to do?
Logged
radio42
Posts: 4012


« Reply #6 on: 8 Dec '11 - 09:01 »
Reply with quoteQuote

Quote
Is it really that difficult for you to just tell me what to do?
Yes it is, if I don't know what exact exeption you are getting.

As already explained in the first reply to your post - these are the 2 most common errors:
a) the native bass.dll is missing in your executable directory (e.g. .\bin\Debug)?
b) you are compiling your app as for 'Any CPU' on a x64 OS and thus need to use the native x64 bass.dll?

You actually never replied to these questions/suggestions.
But without the exact error exception it is all just guessing?!

That's why I pointed you to the docs and the samples provided with Bass.Net - e.g. the 'MyFirstBass'.

To guess again:
Maybe you have not called "BASS_Init" within your code?
Logged
Cody
Guest
« Reply #7 on: 8 Dec '11 - 17:22 »
Reply with quoteQuote

I copied this code into my program. Copied the bass.dll file and test.mp3 file into bin\debug, and when I debug the program I get this message:
TypeInitializeException was unhandled
The type initializer for 'Un4seen.Bass.Bass' threw an exception.

And here's code:
using System;
using Un4seen.Bass;

namespace MyFirstBass
{
    class Program
    {
        static void Main(string[] args)
        {
            // init BASS using the default output device
            if (Bass.BASS_Init(-1, 44100, BASSInit.BASS_DEVICE_DEFAULT, IntPtr.Zero))
            {
                // create a stream channel from a file
                int stream = Bass.BASS_StreamCreateFile("test.mp3", 0, 0, BASSFlag.BASS_DEFAULT);
                if (stream != 0)
                {
                    // play the stream channel
                    Bass.BASS_ChannelPlay(stream, false);
                }
                else
                {
                    // error creating the stream
                    Console.WriteLine("Stream error: {0}", Bass.BASS_ErrorGetCode());
                }

                // wait for a key
                Console.WriteLine("Press any key to exit");
                Console.ReadKey(false);

                // free the stream
                Bass.BASS_StreamFree(stream);
                // free BASS
                Bass.BASS_Free();
            }
        }
    }
}
Logged
radio42
Posts: 4012


« Reply #8 on: 8 Dec '11 - 19:21 »
Reply with quoteQuote

Take a look to what I said about option b)!
- what OS are you running on?
- what .Net Framework have you installed?
- what .Net Framework are you targeting your app?
- and what Bass.Net.dll version are you using the v2.0 or v4.0 assembly.

If you are using the v4.0 Bass.Net.dll version make sure you have the FULL .Net 4 Framework installed!
Logged
Cody
Guest
« Reply #9 on: 8 Dec '11 - 20:00 »
Reply with quoteQuote

Windows 7 x64
.Net 4
Seeing as it's running on my own computer, .Net 4
v4.0

It's getting it to run with the regular bass.dll that gives it problems.
Logged
radio42
Posts: 4012


« Reply #10 on: 8 Dec '11 - 20:40 »
Reply with quoteQuote

As you are running a x64 OS you should take care of your compiler settings.
If you compile your project with the for 'Any CPU' settings - you would need the 64-bit versions of the native BASS.dll!
Or set your build to 'x86' !
This is what I ment with b) in my very first post! See the docs for detailed info - or here:
http://www.bass.radio42.com/help/html/b8b8a713-7af4-465e-a612-1acd769d4639.htm#32vs64


In addition:
Which .Net v4 Framework have you installed?
Note, that there are two v4 Frameworks available:
a) .Net v4 Client Framework (which is e.g. by default installed on Win7)
b) .Net v4 FULL Framework

Bass.Net requires b)!
See here: http://www.un4seen.com/forum/?topic=4932.msg92558#msg92558
« Last Edit: 8 Dec '11 - 20:44 by radio42 » Logged
Cody
Guest
« Reply #11 on: 8 Dec '11 - 21:14 »
Reply with quoteQuote

Where exactly do I change this? I can't seem to find it. And I just put the Full Framework on and it still does not work.
Logged
radio42
Posts: 4012


« Reply #12 on: 9 Dec '11 - 08:15 »
Reply with quoteQuote

Then it is the mentioned x86/x64 issue.
When you are using VisualStudio: Open the project settings and select the 'Build' tag - in there you can specify the 'Platform Target'.
Note: In the VisualStudio Express version this can not be changed as far as I know - so this means you might have to use the x64 bass.dll version!
Logged
Cody
Guest
« Reply #13 on: 9 Dec '11 - 19:24 »
Reply with quoteQuote

That's the one that I have already.
Logged
muntablues
Posts: 191


« Reply #14 on: 9 Dec '11 - 19:47 »
Reply with quoteQuote

Try:

Tools -> Options -> Project and Solution and enable "Show advanced build options". After that go to Build -> Configuration Manager and add x86 platform.

Good luck *gg*
Logged
Cody
Guest
« Reply #15 on: 10 Dec '11 - 05:45 »
Reply with quoteQuote

Try:

Tools -> Options -> Project and Solution and enable "Show advanced build options". After that go to Build -> Configuration Manager and add x86 platform.

Good luck *gg*
It's already set at that.
Logged
Pages: [1]
  Reply  |  Print  
 
Jump to:  

Powered by SMF 1.1.18 | SMF © 2013, Simple Machines