473,396 Members | 2,018 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,396 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
Nov 21 '05 #1
2 1497
I think your problem lies in the assignment to Str, specifically the string
"wav" that you're appending. You have:
Dim Str As Stream =
System.Reflection.Assembly.GetExecutingAssembly(). GetManifestResourceStream(
strNameSpace + "." + wav)


And it should be

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

Where "FILENAME" is the case-sensitive name of the file you embedded as a
resource.

It appears that you're trying to use a variable named wav, rather than the
string value "wav."

Hope that helps,
/m


Nov 21 '05 #2
"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/]

Nov 21 '05 #3

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...
1
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...
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...
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: Alejandro Gaio | last post by:
Hello All, I have a problem that appeared with the NEW VERSION of the vb.net compiler (VS 2008). To resume things, I have a project (call it "DocumentAdministrator") with several forms, and two...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.