473,320 Members | 2,035 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Problem/Error with Embedded Resources (Sound File)

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
Aug 4 '05 #1
1 1712
"Vanessa" <va******@starhub.net.sg>'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/]

Aug 4 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Grzegorz | last post by:
Hi All, I encountered recently the following strange behavior of JS: I need to create a simple page that contains one button. After clicking it there should be generated two short sounds with a...
5
by: Drew | last post by:
Assembly asm = Assembly.GetExecutingAssembly(); me = new Bitmap(asm.GetManifestResourceStream("me.gif")); I have used this before without any problem, but now I get: An unhandled exception...
7
by: Ken Allen | last post by:
OK, for a number of reasons I have needed to begin experimenting with resources sooner than I had planned (I had avoided it for now). Step 1: I built the 'reseditor' application that is in the...
1
by: Stefan Turalski \(stic\) | last post by:
Hi, What I need to do is adding some support for resources files to my application. What I did is: MyAppMain <- startup project MyAppHelper <- project which has MyAppResourcesClass (al a...
0
by: Pablo Jose Almeida da Guia | last post by:
Well.. ...I am using some resource files to make the internationalization of a ASP.NET application. I created a project and three resource files. ------- resource files ------- /strings.txt...
0
by: nthpixel | last post by:
Hey Folks, I am getting the following errors when I try to connect to my db with the MySqlConnection. I added MySql.Data to my Reference list and have the .dll in my bin directory. I also have...
2
by: Vanessa | last post by:
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...
0
by: Chia Lee Lee | last post by:
Hi... I have a problem when i try to insert a sound file (.wav) to my project but system prompt me an error message as follow: “An unhandled exception of type 'System.NullReferenceException'...
8
by: Fred* | last post by:
Hello, I'm using Visual C# 2005 Express. if I create a new "application windows" project and run it (F5), it works well. (an empty window is launched..) as soon as I set the build action to...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.