473,765 Members | 1,994 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.GetExe cutingAssembly( );

// Resources are named using a fully qualified name.

Stream strm =
Asm.GetManifest ResourceStream( Asm.GetName().N ame + "." + Name);

// Reads the contents of the embedded file.

StreamReader reader = new StreamReader(st rm);

return reader.ReadToEn d();

}
}

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

Can any one let me know where i went wrong

Thanks in Advance

thomson

Nov 19 '05 #1
1 1609
A quick guess. You are using Asm.GetName().N ame this returns the name of
the assembly, not necessary what you want. What you want is the
Namespace.FileN ame 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**********@y ahoo.com> wrote in message
news:11******** *************@g 44g2000cwa.goog legroups.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.GetExe cutingAssembly( );

// Resources are named using a fully qualified name.

Stream strm =
Asm.GetManifest ResourceStream( Asm.GetName().N ame + "." + Name);

// Reads the contents of the embedded file.

StreamReader reader = new StreamReader(st rm);

return reader.ReadToEn d();

}
}

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

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
761
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: I've added a few files (images) to an assembly as embedded resources. Within the project folder these files are in a subfolder named "images".
0
854
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, Stefan
1
1735
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 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,
0
1160
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 using a large icon (supports all formats) in many forms in 1 executable, and this seems to result in much code bloat - does this translate to memory bloat at runtime?
5
10284
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 thing??? Bob Rock
0
1179
by: Kyle Kaitan | last post by:
Is there a managed way to both read from *and* write to embedded resources?
0
1039
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 dynamically created images should be instances of System.Web.UI.WebControls.Image...
2
2571
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) to my class library and then accessing them from html with <IMG SRC="res://ResLib.dll/GIF/ResLib.testpic.gif"> The name "ResLib.testpic.gif" comes from
4
1737
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 .... but then I don't know I to access single keys and values inside the same .resources file. I'd like to be able to do something like what is possible with the ResourceManager class but I haven't found a way to use it with embedded resources but only...
0
9566
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10007
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9946
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9832
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6646
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5272
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5413
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3921
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3530
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.