473,396 Members | 1,942 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.

Reading Embedded Resources

Hi all,
I have added a new Item in my Solution Test.sql which has got
some sql scripts and i have changed the Build Action Property of the
file to embedded Resources
private string GetSql(string Name)

{

// Gets the current assembly.

Assembly Asm = Assembly.GetExecutingAssembly();

// Resources are named using a fully qualified name.

Stream strm =
Asm.GetManifestResourceStream(Asm.GetName().Name + "." + Name);

// Reads the contents of the embedded file.

StreamReader reader = new StreamReader(strm);

return reader.ReadToEnd();

}
}

i wrote this function to read the Embedded Resource when it executes
the Stream Reader it gives an Error
System.IO.__UnmanagedMemoryStream

Can any one let me know where i went wrong

Thanks in Advance

thomson

Nov 19 '05 #1
1 1582
A quick guess. You are using Asm.GetName().Name this returns the name of
the assembly, not necessary what you want. What you want is the
Namespace.FileName of your resource. Namespace will be the default
namespace you assigned your assembly. Also, make sure that Name specifies
an extension. You should also look at closing your reader.

Karl

--
MY ASP.Net tutorials
http://www.openmymind.net/
http://openmymind.net/redirector.aspx?documentId=51 - Learn about AJAX!

"thomson" <sa**********@yahoo.com> wrote in message
news:11*********************@g44g2000cwa.googlegro ups.com...
Hi all,
I have added a new Item in my Solution Test.sql which has got
some sql scripts and i have changed the Build Action Property of the
file to embedded Resources
private string GetSql(string Name)

{

// Gets the current assembly.

Asm = Assembly.GetExecutingAssembly();

// Resources are named using a fully qualified name.

Stream strm =
Asm.GetManifestResourceStream(Asm.GetName().Name + "." + Name);

// Reads the contents of the embedded file.

StreamReader reader = new StreamReader(strm);

return reader.ReadToEnd();

}
}

i wrote this function to read the Embedded Resource when it executes
the Stream Reader it gives an Error
System.IO.__UnmanagedMemoryStream

Can any one let me know where i went wrong

Thanks in Advance

thomson

Nov 19 '05 #2

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

Similar topics

0
by: Philipp Seidel | last post by:
Hi there! I did not know, where this topic fits in, so I put it here. I have a minor problem with embedded resources, which puzzles me quite a lot. I'd be glad if anyone can help me on this: ...
0
by: StefanT | last post by:
Hi, there is any way to change some embedded resources at runtime ? I can pull resources from an assembly at runtime but there is any way to change this resources as well. Best regards,...
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...
0
by: schoenfeld1 | last post by:
If I have an executable with a gigabytes of embedded resources, will the CLR loader try to load the resources into memory or does it only load the code segments? The reason I ask is because I am...
5
by: Bob Rock | last post by:
Hello, I'd like to be able to enumerate resources in embedded .resources files like it is possible with external .resources files using the ResourceReader class. Is there a way to do such a...
0
by: Kyle Kaitan | last post by:
Is there a managed way to both read from *and* write to embedded resources?
0
by: PontiMax | last post by:
Hi, 'til now my resource files did simply consist of string entries. Now I intend to use images as embedded resources. How can that be done? Do I have to use a resource editor? The...
2
by: Dan | last post by:
Hi, How do I embed a picture (gif for instance) in a dll using VB.NET so that the picture can be used in a html page with the res protocol? I have tried adding pictures (as Embedded resources)...
4
by: Bob Rock | last post by:
Hello, I'd like to programmatically access keys and values of on .resources file embedded in my assembly. I've seen that the assembly class provides the GetManifestResourceStream method .......
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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...
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.