Click here to Skip to main content
14,575,520 members
   

C#

 
GeneralRe: How can I augment an array inside an .exe-file? Pin
Eddy Vluggen2-May-20 21:27
professionalEddy Vluggen2-May-20 21:27 
GeneralRe: How can I augment an array inside an .exe-file? Pin
arnold_w2-May-20 21:41
Memberarnold_w2-May-20 21:41 
GeneralRe: How can I augment an array inside an .exe-file? Pin
Eddy Vluggen2-May-20 21:45
professionalEddy Vluggen2-May-20 21:45 
GeneralRe: How can I augment an array inside an .exe-file? Pin
Dave Kreskowiak3-May-20 4:27
mveDave Kreskowiak3-May-20 4:27 
GeneralRe: How can I augment an array inside an .exe-file? Pin
Eddy Vluggen3-May-20 10:00
professionalEddy Vluggen3-May-20 10:00 
GeneralRe: How can I augment an array inside an .exe-file? Pin
Dave Kreskowiak3-May-20 15:01
mveDave Kreskowiak3-May-20 15:01 
GeneralRe: How can I augment an array inside an .exe-file? Pin
arnold_w3-May-20 22:23
Memberarnold_w3-May-20 22:23 
GeneralRe: How can I augment an array inside an .exe-file? Pin
Member 79891223-May-20 23:35
MemberMember 79891223-May-20 23:35 
arnold_w wrote:
If you think about it, this would be very useful to avoid having a (separate) file that remembers the user's preferences (e.g. list of recently used documents, use spaces instead of spaces, etc). When you exit the application, you would just update the array that contains the user preferences (of course, since the executing file it locked, you first rename the executing file, then create a new file with the original file name and then self-destruct the original file).
Huh? Are you serious? Or do I completely misunderstand what you want to do?

It sounds to me as if you want to save one user's preferences in the executable file itself, writing back a modified .exe after removing the old one. Right? If that is it, it is the craziest proposal I have seen for a while!

Re. user preferences: We are not in the Linux world. Using separate files (type ".ini" or ".rc_something") is NOT the proper way to do it. User preferences are stored in under HKCU in the registry. How do you plan to handle different users of the same executable - or do you plan to give each user his own executable for his own private modification?

Under any circumstances: Consider executables as non-writable files - most of all in a managed world. You have left the management of modules to dotNet, and you cannot poke around with a long stick into that management. What you are suggesting is a sort of self-modifying code. Leave that to the assembler guys! Self-modifying code is completely unmanagable! (not only in the sense of dotNet, but generally speaking)

Sure, you are only modifying parameters to some funcitons, but it is not seen as external input at run time, it is hidden within the code itself. So it appears as the code has been changed from one run to another, with no external input. That is functionally identical to the code modifying itself.

In a managed runtime, you do not control the memory location of the managed modules - that is an essential part of the management (that you have left to others). Although you can build a single, fully compiled .exe-file from C#, this is really not the standard way: Assemblies are distributed in a "half-compiled" form, as CIL (Common Intermediate Language), where the final compilation steps are done when the assembly is first used. Until this last complilation is done (this is where differnet instruction sets etc. are taken into consideration), memory addresses are not known. At run time, the addresses may vary from one machine/CPU to another.

So there is no "linker script" for the entire application the way you seem to expect. It is all done dynamically. When you create a self-contained .exe, you are really doing part of the run time handling in advance. But since the "real" dotNet assumes that this is done dynamically, there are no provisions for e.g. controlling memory addresses from outside. Memory placement is handled in other ways, so there is no need to. Or reason to. It doesn't belong in a managed environment.

If you feel that your proposed solution is the only viable alternative, then I don't think managed code is for you. Consider assembly code, or possibly pure C.
GeneralRe: How can I augment an array inside an .exe-file? Pin
Dave Kreskowiak4-May-20 3:26
mveDave Kreskowiak4-May-20 3:26 
GeneralRe: How can I augment an array inside an .exe-file? Pin
Member 79891222-May-20 11:49
MemberMember 79891222-May-20 11:49 
GeneralRe: How can I augment an array inside an .exe-file? Pin
arnold_w2-May-20 21:21
Memberarnold_w2-May-20 21:21 
GeneralRe: How can I augment an array inside an .exe-file? Pin
Robert Bushlow7-May-20 18:59
MemberRobert Bushlow7-May-20 18:59 
GeneralRe: How can I augment an array inside an .exe-file? Pin
arnold_w7-May-20 19:37
Memberarnold_w7-May-20 19:37 
GeneralRe: How can I augment an array inside an .exe-file? Pin
Robert Bushlow8-May-20 2:32
MemberRobert Bushlow8-May-20 2:32 
GeneralRe: How can I augment an array inside an .exe-file? Pin
arnold_w8-May-20 3:42
Memberarnold_w8-May-20 3:42 
AnswerRe: How can I augment an array inside an .exe-file? Pin
Eddy Vluggen8-May-20 3:53
professionalEddy Vluggen8-May-20 3:53 
GeneralRe: How can I augment an array inside an .exe-file? Pin
Robert Bushlow8-May-20 4:02
MemberRobert Bushlow8-May-20 4:02 
AnswerRe: How can I augment an array inside an .exe-file? Pin
Richard MacCutchan2-May-20 22:17
mveRichard MacCutchan2-May-20 22:17 
AnswerRe: How can I augment an array inside an .exe-file? Pin
Pete O'Hanlon3-May-20 10:09
subeditorPete O'Hanlon3-May-20 10:09 
AnswerRe: How can I augment an array inside an .exe-file? Pin
Gerry Schmitz3-May-20 18:54
mveGerry Schmitz3-May-20 18:54 
QuestionAsync await error Pin
Carlos581-May-20 11:01
MemberCarlos581-May-20 11:01 
AnswerRe: Async await error Pin
Mycroft Holmes1-May-20 12:00
professionalMycroft Holmes1-May-20 12:00 
GeneralRe: Async await error Pin
Carlos581-May-20 12:08
MemberCarlos581-May-20 12:08 
GeneralRe: Async await error Pin
Mycroft Holmes1-May-20 12:18
professionalMycroft Holmes1-May-20 12:18 
AnswerRe: Async await error Pin
Carlos582-May-20 4:01
MemberCarlos582-May-20 4:01 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.