user4388177
user4388177

Reputation: 2613

Changing strings after deployment .NET

We have a big project, just English language.

Business users require changes to the text in the application sometimes and they are forced to wait until the next release to get the changes.

One possible solution would be to have the strings into the database, another would be in a text file not embedded into the assembly to be able to change it after deployment.

The resources file are attractive as they have already a framework in place for creating classes and properties for access, but, as far as I understood, they are just embedded into the assembly and cannot be modified (easily) after.

What would be the best way to approach this problem?

Upvotes: 2

Views: 283

Answers (3)

user4388177
user4388177

Reputation: 2613

I think I'll use:

https://msdn.microsoft.com/en-us/library/system.resources.resourcemanager.createfilebasedresourcemanager(v=vs.110).aspx

So I can create an external resource file and just copy the output to the release folder.

What do you think of this approach?

Is it fast enough?

Upvotes: -1

VMAtm
VMAtm

Reputation: 28355

No, you are wrong - resources can be compiled apart of your other code, and you can provide an update for your application:

Creating Resource Files for Desktop Apps

Resources in .resources Files You can use the System.Resources.ResourceWriter class to programmatically create a binary resource (.resources) file directly from code. You can also use Resource File Generator (Resgen.exe) to create a .resources file from a text file or a .resx file.

After you create the .resources file, you can embed it in a run-time executable or library by including the language compiler's /resource switch, or embed it in a satellite assembly by using Assembly Linker (Al.exe).

As you are using Visual studio, you can easily add the resources files via its interface, and then you'll have an easy way to edit it.

I suggest you to:

  1. Create a main resource file there the main resources are stored. This file will be embed in a libraries of your application. Here you can store non-updatable resources.
  2. Create a localized resources for the en-US culture - Visual studio will compile it in a separate file so you can easily update it without recompiling whole project.

Or:

  1. Change the default behaviour of the VS and move all of your resources away from project into a separate library.

As you are using the VS 2010, I assume your project is a .NET 3.0, so the right link for the MSDN is:

Upvotes: 3

DevEstacion
DevEstacion

Reputation: 1977

Try using the app.Config.

The main benefit of the app.config is that It's directly attached to your executable. Once you build your solution, the app.config gets copied together with the executable.

From What is App.config in C#.NET? How to use it?:

At its simplest, the app.config is an XML file with many predefined configuration sections available and support for custom configuration sections. A "configuration section" is a snippet of XML with a schema meant to store some type of information.

Settings can be configured using built-in configuration sections such as connectionStrings or appSettings. You can add your own custom configuration sections; this is an advanced topic, but very powerful for building strongly-typed configuration files.

Source for app.config in msdn: How to: Add an Application Configuration File to a C# Project

Upvotes: 0

Related Questions