473,943 Members | 15,092 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

GetManifestReso urceStream

Hi,

I'm writing a WinForms app in C# which requires a 3rd party executable
called htmldoc.exe in order to create PDF documents from HTML files. To
prevent the app from not functioning if the user accidentally deletes this
file, I'm investigating the possibility of making it an Embedded Resource.
When the app starts up, it will search for the executable and "extract" it
if it's missing. I found the following code on the Net:

using Microsoft.Win32 ;
using System;
using System.IO;
using System.Reflecti on;
using System.Runtime. InteropServices ;
using System.Windows. Forms;

byte[] abytFile;
Assembly objAssembly = Assembly.GetExe cutingAssembly( );
Stream objStream = objAssembly.Get ManifestResourc eStream("htmldo c.exe");
abytFile = new Byte[objStream.Lengt h]; // this line errors
objStream.Read( abytFile, 0, (int)objStream. Length);
FileStream objFileStream = new
FileStream(Path .GetDirectoryNa me(objAssembly. Location) + "\\htmldoc.exe" ,
FileMode.Create );
objFileStream.W rite(abytFile, 0, (int)objStream. Length);
objFileStream.C lose();

This compiles with no errors, but errors on the line I've indicated. The
error string is:
System.NullRefe renceException: Object reference not set to an instance of an
object.\r\n at HBQ.frmMDI.frmM DI_Load(Object sender, EventArgs e) in
c:\\documents and settings\\mrae\ \my documents\\visu al studio
projects\\hbq\\ hbq\\frmmdi.cs: line 851

which indicates that the Stream has not been created correctly - if I hover
the cursor over the objStream variable, it shows "<undefined value>"

I'm slightly puzzled as to what I'm doing wrong - the executable is
definitely there and has been added to the project with its Build Action set
to Embedded Resource.

Any assistance gratefully received.

Best regards,

Mark Rae
Nov 16 '05 #1
1 5605
"Mark Rae" <ma**@markrae.c o.uk> wrote in message
news:uT******** ******@TK2MSFTN GP10.phx.gbl...

D'oh! Forgot to prefix the resource filename with the project's default
namespace!

Sorry for the pointless post... :-(
Nov 16 '05 #2

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

Similar topics

0
508
by: Steve Guidi | last post by:
Hello, I'm developing an application that periodically reads embedded assembly resources. The resources are text-based, and are about 3-7KB in size, and the application accesses them by calling the Assembly.GetManifestResourceStream() method. During a long period of execution, I've noticed that the memory usage of the application increases; specifically, it appears that the System.IO.__UnmanagedMemoryStream returned by
1
660
by: Mark Rae | last post by:
Hi, I'm writing a WinForms app in C# which requires a 3rd party executable called htmldoc.exe in order to create PDF documents from HTML files. To prevent the app from not functioning if the user accidentally deletes this file, I'm investigating the possibility of making it an Embedded Resource. When the app starts up, it will search for the executable and "extract" it if it's missing. I found the following code on the Net: using...
0
1656
by: Darryn Ross | last post by:
Hi, I am trying to use GetManifestResourceStream and i keep getting a NULL exception error?? i cannot understand why? private Bitmap _buttonFace; .. ..
6
8579
by: Saya | last post by:
Hello, This is a repost 'cause I haven't solve the problem: I can't use the System.Drawing class 'Image.FromStream' in the CompactFramework environment. What I've done with respect to Brendan's suggestion is as follows: Brendan, thanks for the reply! I'm a little bit further now, but not yet finished. I've come this far, see code below: Stream s =
0
1402
by: Leszek Taratuta | last post by:
Hello, I would like to retrieve an image from embedded resources. Then I need to use it in all over my web app, usually as an icon for ImageButtons. My idea was to retrieve the image just once using GetManifestResourceStream, store it somewhere as a temporary file, and then use URL to this temporary file. How to accomplish this task? Thanks,
15
3672
by: kurt sune | last post by:
Anybody has a tip of where to find info/example how to retrieve an icon from a .RESX-file? /k
1
5304
by: Tom Edelbrok | last post by:
I'm reading embedded bitmaps from an EXE project and everthing works fine. I do a GetExecutingAssembly, followed by setting a stream object to MyAssemblyName.GetManifestResourceStream("MyApp.MyBitmap.BMP"). Note that the BMP is set as an embedded resource via it's properties in the VB.NET project. Finally, I do a "New Bitmap(MyStream)" to fetch the resource into a Bitmap object and job done - I can display it in a PictureBox. However,...
2
2785
by: Jonathan Crawford | last post by:
Hi I downloaded a sample from here http://64.78.52.104/FAQ/WinForms/default.asp#44 5.57 How do I display a column of buttons such as pushbuttons or combobox buttons? I can run the project ok and it works as intended but can't get the functionality to work with my project.
1
1981
by: WT | last post by:
Hello, My 1.1 web site was using GetManifestResourceStream to get strategic .js files embedded as resources in the site assembly, but now it is no more allowed to embed resources by specifying a build process of embedding. ,Now we have the App_GlobalResources so how to use code like this with it : Stream st = Assembly.GetExecutingAssembly().GetManifestResourceStream(resourceID);
6
21681
by: CSharpProgrammer | last post by:
Hi, I followed an example that loads an embedded resource http://support.microsoft.com/kb/324567 That works just fine and dandy. My problem is that my namespaces are setup a bit differently. I tried using both namespaces and neither seem to work. I'm assuming it shoud be the First_namespace, since that is the project namespace.
0
10138
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
9970
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
11537
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
11131
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...
0
9865
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
8222
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
7391
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();...
1
4912
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
4512
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.