473,698 Members | 2,322 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1730
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.GetExe cutingAssembly( );
using(Stream s = asm.GetManifest ResourceStream( "namespace.file name.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******** ******@tk2msftn gp13.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.GetExe cutingAssembly( );
using(Stream s = asm.GetManifest ResourceStream( "namespace.file name.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
2866
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 embedded scripting language (a very limited one). I would like to rip it out and replace it with Python. I am thinking that this would be relatively simple since the scripting language is a very small interface between the UI and the engine --...
2
1467
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 version="1.0"?> <!DOCTYPE foo > <foo> .... document instance here ... </foo>
1
1833
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 Python. To be more specific: My app should: 1. Parse an input file. 2. Call a script in some scripting language, to generate an output file, for example in C++. For task 2 I need to call an embedded interpreter, and also provide call backs from...
2
8947
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 = "C:\photo.bmp" Me!Photograph.Class = "Paint.Picture" Me!Photograph.OLETypeAllowed = acOLEEmbedded Me!Photograph.SourceDoc = strPathname Me!Photograph.Action = acOLECreateEmbed
0
1210
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 pertaining to variables, I would like to have that "variables.resource" file within that folder and be able to call it from there instead of calling it from the executing assembly area. So far I am unable to figure out the complete syntax of...
0
1172
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 mathematics to various systems, most functions are hard-coded but we want to embed a scripting language to allow arbitrary functions to be used in the numeric engines within the library, and am using Python for this.
3
1253
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 had a few icons and bitmaps included in the project with their build action set as "Embedded Resource". Through code I generated some bitmaps using these items for the user to see. Nothing
1
3079
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 found this article very good and it clarified for me what needs doing. Now I have an example application that almost works, but it is far from reliable. If I run this several times I get crashes telling me that the heap is modified after deallocation....
0
950
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 one file and the unit tests in another. I figure if I just put a if __name__ == '__main__": import unittest blah, blah, blah block at the end of each source file, I'll end up with a cleaner
0
8676
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
9164
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9029
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
8898
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
8870
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...
1
6524
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5860
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
4619
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3051
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

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.