5

I have a resource file where I am storing connection string etc for a class library (I cant use an App.config, don't ask why). It was my assumption (might be a stupid one) that I would be able to modify the .rex file out side of the complied assembly at runtime to be able to change connection string through environments without recompiling the assembly each time, can someone verify my assumption and if possible tell me how to do it?

Cheers

Manfred Radlwimmer
  • 13,257
  • 13
  • 53
  • 62
user728584
  • 2,135
  • 2
  • 21
  • 24
  • The proper place to store configuration information such as connection string is app.config / web.config file. Resources are not well suited for it as you can't easily change them once your binary has been compiled. Please let us know what is the problem with storing connection string in app.config so we can come up with possible work-arounds. – Andrew Savinykh May 15 '11 at 04:04
  • So I cant use a resource file for this then, no way of changing the file once complied. Problem is calling app to C# is Ruby and doesn't have a app/web.config – user728584 May 15 '11 at 04:06
  • 2
    Copy the compiled resources to a temp directory first and then you can modify it as much as you like :-) – Mohamed Nuur May 15 '11 at 04:09
  • Hi Mohamed Nuur, sounds good, can you elaborate more on how to do this? – user728584 May 15 '11 at 04:16
  • Any exe has an app.config. Any exe. If it is ruby, if it is python, if it is JScript, anything. You only need to know the exe name, and you know the config file name If the exe is XXXX.exe, then the config file is XXXX.exe.config . If your ruby thing runs under ruby.exe, then the config file is ruby.exe.config . (I don't know ruby so I don't know if that answer actually applies - just giving you an example for how it would work) – Cheeso May 15 '11 at 04:42

2 Answers2

2

You can disassemble assembly, edit resources and assemble it again.

You can find some info here.

Nasreddine
  • 36,610
  • 17
  • 75
  • 94
Alex Aza
  • 76,499
  • 26
  • 155
  • 134
1

If it's a text resource, you may try to just replace the characters.

I have successfully modified a SQL query which was included in .EXE assembly with Notepad++. I made sure though, that the number of characters was not altered.

Marcel
  • 15,039
  • 20
  • 92
  • 150