473,391 Members | 1,522 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,391 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 1714
"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: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.