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

Embedding a file into a project...

I have the need for a few XSLT files that I'd like to embed within my DLL. I don't want to be forced to have to deploy each of these XSLT files as well as my DLL... because if one file was missing, it could cause major problems.

How would I go about adding an XSLT file to an assembly and then, how to pull it out? Assuming it has something to do with the resource files.

-AC
Nov 15 '05 #1
2 1718
Add the file to your project, and set its BuildAction property to Embedded
Resource. When the project is compiled, you'll be able to see a reference to
the embedded file using ILDASM - look in the manifest for the line that
begins with .mresource.

To load the file, use something like:
Assembly asm = Assembly.GetExecutingAssembly();
using(Stream s = asm.GetManifestResourceStream("namespace.filename. ext"))
{
// use stream here...
}

--
Mickey Williams
Author, "Microsoft Visual C# .NET Core Reference", MS Press
www.servergeek.com

Nov 15 '05 #2
Exactly what I was looking for... thanks Mickey.
-AC

"Mickey Williams" <my first name at servergeek.com> wrote in message
news:uI**************@tk2msftngp13.phx.gbl...
Add the file to your project, and set its BuildAction property to Embedded
Resource. When the project is compiled, you'll be able to see a reference to the embedded file using ILDASM - look in the manifest for the line that
begins with .mresource.

To load the file, use something like:
Assembly asm = Assembly.GetExecutingAssembly();
using(Stream s = asm.GetManifestResourceStream("namespace.filename. ext"))
{
// use stream here...
}

--
Mickey Williams
Author, "Microsoft Visual C# .NET Core Reference", MS Press
www.servergeek.com

Nov 15 '05 #3

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

Similar topics

2
by: Roose | last post by:
With some googling I have found these resources: http://docs.python.org/ext/win-dlls.html http://www.python.org/doc/faq/windows.html I have a large Win32/MFC/C/C++ application that has an...
2
by: campbell.shaun | last post by:
The application I am writing uses XML files for validation. I've been able to set up my xml files so that I can share validation for common fields using external entities. eg <?xml...
1
by: Tommy Nordgren | last post by:
I want to write an application that embeds and extends (at least) the Python and Perl interpreters. Now i want to find as much as possible about the Python tools used for extending and embedding...
2
by: Lyn | last post by:
I am trying to embed a picture into a Bound Object Frame (Me!Photograph) with the following code which is based on MS article http://support.microsoft.com/?id=158941: strPathname =...
0
by: MikeY | last post by:
With Reference/Resource is there a way of embedding the .resource file within a folder of my application instead of having it in the main project /executing assembly area. i.e. if I have a folder...
0
by: Fozzie | last post by:
Hi, I have a problem which is quite circular, and hopefully either someone has encountered something similar or has a reason why this will not work. We have a COM library providing...
3
by: Bob Trabucco | last post by:
Hello all, I have a ASP.NET website written using VS 2003. I am in the process of migrating it up to 2005. There is one problem I just can't seem to solve. In my original VS 2003 project I...
1
by: freesteel | last post by:
I have posted about this problem before. SInce then I found a much better article to help with embedding python in a multithreaded application: http://www.linuxjournal.com/article/3641 I...
0
by: Roy Smith | last post by:
I'm starting a new project and am thinking of embedding my unit tests right in the source files. I've used unittest before, and I'm happy with it, but I've always used it with the source code in...
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
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
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...
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.