Click here to Skip to main content
15,886,823 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello,

i am trying to add resource file dynamically and using bellow code it's working fine but once it's create i have to manually add that using

right-click->include in project can you please tell me how to achieve this thing dynamically (with out right-click->include in project)

C#
using (ResXResourceWriter resx = new ResXResourceWriter(path))
{
resx.AddResource("valFirstname", "Prénom Must requis");
resx.AddResource("valLastname", "Nom Must requis");
resx.AddResource("valPassword", "Mot de passe doit requise");
resx.AddResource("valUsername", "Nom d'utilisateur Doit requis");
resx.Generate();
resx.Close();
}

Please answer me i am stuck in this
Posted
Updated 12-Sep-14 4:32am
v4
Comments
Sinisa Hajnal 12-Sep-14 6:08am    
Why would you do that? Why not create empty resource and fill it as you go?
chirag.jdk 12-Sep-14 8:28am    
there is requirement to create dynamically resource, user can select any language and depend on that we have to create resource file

1 solution

This should help:
http://msdn.microsoft.com/en-us/library/gg418542(v=vs.110).aspx[^],
specifically this:
MSDN:
You cannot embed a .resx file in a runtime executable or compile it into a satellite assembly. You must convert your .resx file into a binary resource (.resources) file by using the Resource File Generator (Resgen.exe). The resulting .resources file can then be embedded in an application assembly or a satellite assembly. For more information, see Creating Resource Files for Desktop Apps.

The link for the other part is here
http://msdn.microsoft.com/en-us/library/xbx3z216(v=vs.110).aspx[^]
It basically state that you need to run the resx thorugh resgen.exe, then either compile the resulting .resource file into the assembly or link it via AI.exe. Neither of which are much better than option of adding directly I suppose.

One thing you can do is create a specific resources assembly that gets referenced by the consuming project - as long as the latter remains agnostic of the resources build number, you can just re-deploy a new version of the resources dll.

Disclaimer: I haven't done a lot of this stuff in a while - hopefully someone will provide a simpler solution.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900