Problem/Error with Embedded Resources (Sound File)

Discussion in 'ASP .Net' started by Vanessa, Aug 4, 2005.

  1. Vanessa

    Vanessa Guest

    Anyone know how to embed sound file to vb.net project, then play the sound
    file?

    I have searched the web for example... and download the example and when
    run, it works perfectly.

    But when i try to insert a sound file (.wav) to my project and set the Build
    Action to "Embedded Resources". And then I use the same code as what I saw
    in the example, but it gives me an error,

    An unhandled exception of type 'System.NullReferenceException' occurred in
    Application.exe
    Additional information: Object reference not set to an instance of an
    object.

    When i debug, it prompt an error at the if statement, when my mouse move
    over to Str, it's nothing. Anybody knows what's wrong or what i did wrong?
    Dim strNameSpace As String =
    System.Reflection.Assembly.GetExecutingAssembly().GetName().Name.ToString()

    Dim Str As Stream =
    System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream(
    strNameSpace + "." + wav)

    if Str.CanRead Then

    Regards
    Vanessa
     
    Vanessa, Aug 4, 2005
    #1
    1. Advertising

  2. Vanessa

    Jan Hyde Guest

    "Vanessa" <>'s wild thoughts were
    released on Thu, 4 Aug 2005 21:15:46 +0800 bearing the
    following fruit:

    >Anyone know how to embed sound file to vb.net project, then play the sound
    >file?
    >
    >I have searched the web for example... and download the example and when
    >run, it works perfectly.
    >
    >But when i try to insert a sound file (.wav) to my project and set the Build
    >Action to "Embedded Resources". And then I use the same code as what I saw
    >in the example, but it gives me an error,
    >
    >An unhandled exception of type 'System.NullReferenceException' occurred in
    >Application.exe
    >Additional information: Object reference not set to an instance of an
    >object.
    >
    >When i debug, it prompt an error at the if statement, when my mouse move
    >over to Str, it's nothing. Anybody knows what's wrong or what i did wrong?
    >Dim strNameSpace As String =
    >System.Reflection.Assembly.GetExecutingAssembly().GetName().Name.ToString()
    >
    >Dim Str As Stream =
    >System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream(
    >strNameSpace + "." + wav)
    >
    >if Str.CanRead Then
    >


    Please don't post to more than two or three groups at a
    time.

    Firstly strNameSpace doesn't neccesarily contain the
    namespace of your resource.

    Secondly, where's the filename of this resource?



    Jan Hyde (VB MVP)

    --
    I was shopping around for a car, and one salesman says,
    "You look like the kind of guy who'd want the AM/FM radio with
    removable face plate, the trunk-mounted Cd player, with 8 speakers
    and remote contol."

    I hate being stereotyped.

    (David Reihmer)

    [Abolish the TV Licence - http://www.tvlicensing.biz/]
     
    Jan Hyde, Aug 4, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Johann Blake
    Replies:
    0
    Views:
    502
    Johann Blake
    Dec 17, 2003
  2. Luc The Perverse

    Sound Quality In Sound API

    Luc The Perverse, Oct 30, 2005, in forum: Java
    Replies:
    4
    Views:
    1,513
    Andrew Thompson
    Oct 31, 2005
  3. Replies:
    0
    Views:
    558
  4. Russell E. Owen
    Replies:
    0
    Views:
    736
    Russell E. Owen
    Sep 8, 2006
  5. Replies:
    1
    Views:
    122
Loading...

Share This Page