473,804 Members | 2,255 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Embedding a resource at runtime

Hi there. Does anyone know if it's possible to embed a new resource into an
assembly at runtime as well as update an existing (assembly) resource. Any
assistance would be appreciated. Thanks.
Jun 6 '06 #1
11 3354
Dave,

Do you want to do this to an assembly that is loaded in the runtime? If
that is the case, then this is not possible. Changing the assembly at
runtime is a bad, bad idea. If you need to manage resources (and I use this
term not in the .NET space, but as a general term) in a dynamic manner, then
you should have some sort of storage solution to do that.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Dave Brown" <no_spam@_nospa m.com> wrote in message
news:Ol******** ******@TK2MSFTN GP04.phx.gbl...
Hi there. Does anyone know if it's possible to embed a new resource into
an assembly at runtime as well as update an existing (assembly) resource.
Any assistance would be appreciated. Thanks.

Jun 6 '06 #2
> Do you want to do this to an assembly that is loaded in the runtime? If
that is the case, then this is not possible. Changing the assembly at
runtime is a bad, bad idea. If you need to manage resources (and I use
this term not in the .NET space, but as a general term) in a dynamic
manner, then you should have some sort of storage solution to do that.

Hope this helps.


Thanks for the feedback. In my particular case however, adding and updating
resources in the assembly (exe) itself would have been the simplest way to
go for my users. I wanted to avoid dealing with extraneous file(s) that is
and just ship one ".exe". Perhaps a religious issue but the specialized
nature of my application actually lends itself to this technique (it
involves the processing of resources). Since it's not doable however I'll
have to package them up another way. In any case, thanks again
(appreciated).
Jun 6 '06 #3
Dave,

It's one thing to process resources in an assembly that you actually
don't load in the CLR, but to do it in an assembly already loaded in the
CLR, that's just not feasible.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Dave Brown" <no_spam@_nospa m.com> wrote in message
news:%2******** ********@TK2MSF TNGP04.phx.gbl. ..
Do you want to do this to an assembly that is loaded in the runtime? If
that is the case, then this is not possible. Changing the assembly at
runtime is a bad, bad idea. If you need to manage resources (and I use
this term not in the .NET space, but as a general term) in a dynamic
manner, then you should have some sort of storage solution to do that.

Hope this helps.


Thanks for the feedback. In my particular case however, adding and
updating resources in the assembly (exe) itself would have been the
simplest way to go for my users. I wanted to avoid dealing with extraneous
file(s) that is and just ship one ".exe". Perhaps a religious issue but
the specialized nature of my application actually lends itself to this
technique (it involves the processing of resources). Since it's not doable
however I'll have to package them up another way. In any case, thanks
again (appreciated).

Jun 6 '06 #4
> It's one thing to process resources in an assembly that you actually don't
load in the CLR, but to do it in an assembly already loaded in the CLR,
that's just not feasible.


I really didn't think so since updating a running executable isn't normally
viable as you said (but I'm fairly new to .NET so I chanced it). Do you know
off-hand how it can be done for an assembly that isn't currently loaded
(without relying on command line tools if possible - I normally prefer to
avoid shelling out to launch external utilities). Thanks.
Jun 6 '06 #5
Why don't you duplicate the EXE, embed the resources in the copy, and replace the running exe with the new one, when they exit the
application?

Cheers,

Stu

Nicholas Paldino [.NET/C# MVP] wrote:
Dave,

Do you want to do this to an assembly that is loaded in the runtime? If
that is the case, then this is not possible. Changing the assembly at
runtime is a bad, bad idea. If you need to manage resources (and I use this
term not in the .NET space, but as a general term) in a dynamic manner, then
you should have some sort of storage solution to do that.

Hope this helps.

Jun 6 '06 #6
That's a really bad idea.

What if there is a permission set granted to the assembly based on the
hash? Or if the assembly has a strong name? Verification of the assembly
goes out the window now.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard. caspershouse.co m

"Stuart Carnie" <st***********@ nospam.nospam> wrote in message
news:44******** ******@nospam.n ospam...
Why don't you duplicate the EXE, embed the resources in the copy, and
replace the running exe with the new one, when they exit the application?

Cheers,

Stu

Nicholas Paldino [.NET/C# MVP] wrote:
Dave,

Do you want to do this to an assembly that is loaded in the runtime?
If that is the case, then this is not possible. Changing the assembly at
runtime is a bad, bad idea. If you need to manage resources (and I use
this term not in the .NET space, but as a general term) in a dynamic
manner, then you should have some sort of storage solution to do that.

Hope this helps.


Jun 6 '06 #7
I didn't say it was a good idea :)

I was providing some ideas, given the original question was regarding the possibility of embedding a new resource in their
*existing* executable. Yes, there are side effects, which you have duly pointed out - the assembly cannot be strongly named, and
it can not be verified, therefore posing a severe security risk.

Cheers,

Stu

Nicholas Paldino [.NET/C# MVP] wrote:
That's a really bad idea.

What if there is a permission set granted to the assembly based on the
hash? Or if the assembly has a strong name? Verification of the assembly
goes out the window now.

Jun 6 '06 #8
>I didn't say it was a good idea :)

I was providing some ideas, given the original question was regarding the
possibility of embedding a new resource in their *existing* executable.
Yes, there are side effects, which you have duly pointed out - the
assembly cannot be strongly named, and it can not be verified, therefore
posing a severe security risk.


Thanks for the suggestion. In addtion to the above issues however, it's an
unwieldy solution :) and one I doubt will even work. It's unlikely I can
copy a running executable without encountering some type of sharing
violation nor could I copy it back to itself for the similar reasons (so who
will do this copying). Even if it was doable, it would be a dangerous
venture trying to copy it back to itself while still running (proper
synchronization would be required but this is outside my control).
Jun 6 '06 #9
Actually, it is possible and various techniques are available to implement a "self deleting executable", see http://tinyurl.com/eb9o4.


Dave Brown wrote:
I didn't say it was a good idea :)

I was providing some ideas, given the original question was regarding the
possibility of embedding a new resource in their *existing* executable.
Yes, there are side effects, which you have duly pointed out - the
assembly cannot be strongly named, and it can not be verified, therefore
posing a severe security risk.


Thanks for the suggestion. In addtion to the above issues however, it's an
unwieldy solution :) and one I doubt will even work. It's unlikely I can
copy a running executable without encountering some type of sharing
violation nor could I copy it back to itself for the similar reasons (so who
will do this copying). Even if it was doable, it would be a dangerous
venture trying to copy it back to itself while still running (proper
synchronization would be required but this is outside my control).

Jun 6 '06 #10

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

Similar topics

2
2874
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 --...
1
1922
by: amit | last post by:
Hello, I am currently studying how to embedd python. I am developing a graphical C++ application. My goal is to embedd python script that will control some kind of animation. I have some questions about python embedding: 1) Is there a good text book or other resource on embedding/extending? (I find it hard to learn only by the tutorial and C/Python API from the python.org site)
0
1218
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...
2
1798
by: Matt | last post by:
I'm working on a plug-in for an application called DesktopSideBar for Windows. It emulates to some degree the Longhorn sidebar. The SDK for DesktopSideBar supports .NET plug-in development through COM Interop and a provided reference DLL. In the SDK are two included samples... One, called RecycleBin is written entirely in unmanaged C++ as a normal DLL. The second, StickerPanel, is written in C#. My first exercise was porting StickerPanel...
3
12139
by: UJ | last post by:
I've got an image I want to embed in a dll to use on a screen later. I've got it in a resource file, got it to compile in to the dll. The problem is getting it back out. It seems like my problem is in the get resource code. The code I'm using is: System.Reflection.Assembly myAssembly; myAssembly = this.GetType().Assembly;
3
4093
by: Praveen | last post by:
Hi, I have a control that currently embeds it's images and script files as resources (by marking them as 2.0's WebResourceAttribute) and lets the runtime handle the streaming of the files to the client. This control now also uses a html file (which gets used as a "dialog" during runtime) and I would like to embed this html file as an assembly resource (just like the above images and scripts) to help make deploying my control's...
1
322
by: gavinpaterson | last post by:
Dear Pythoners, I am writing as I am having trouble embedding a Python program into a Win XP C++ console application. I have written a script file for importing and I am trying to use the example for "Pure Embedding" found in the product documentation. The program fails to successfully execute past the line:
2
1626
by: Wilfried Mestdagh | last post by:
Hi, I create a new cursor like this: Bitmap bmp = new Bitmap(fileName); panel1.Cursor = new Cursor(bmp.GetHicon()); But now I want to embed the image in the executable. I have already add the *.ICO file to the project, but how to access it in code ?
12
5280
by: TS | last post by:
i have a need to possibly enable mutli language support. What benefit do i get by using a resource file instead of a custom xml solution? thanks!
0
9714
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
9594
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
10599
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
10346
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
10090
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
9173
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...
0
5673
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4308
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
3832
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.