Mono Support Can I add new resource strings using DB resource model? (Closed)

Viewed 16715 time(s), 3 post(s), 12/28/2011 5:00:13 PM - by grant.stone007
12/28/2011 5:00:13 PM
647 Reputation 69 Total posts

I am using the DB resource model. Is it possible to add new resources? for example...

1. I added new record to table LocalizationSource
Source=MonoSoftware.MonoX.MonoX.Resources.PageResources
ResourceKey=myKey
2. I added realted record in LocalizationString with Data=Hello World.

I thought I could implement new resource in markup something like this...

<asp:Literal ID="Literal1" runat="server" Text="<%$ Code: PageResources.myKey %>"></asp:Literal>

but I get an error: BC30456: 'myKey' is not a member of 'MonoSoftware.MonoX.Resources.PageResources'.

I obviously do not understand how MonoX resource work. Please advise if there is way to implement my own resource strings.

1
12/29/2011 3:42:36 PM
15993 Reputation 2214 Total posts

Hi,

this strongly typed resource access can't be accomplished with the DB resource provider because all newly added resource keys are not compiled into the assembly. Strongly typed keys are only available to default MonoX keys as they were added with the Visual Studio with ResourceManager provider. When you use DB resource provider you need to access newly added keys with loosely typed strings via resource manager under the e.g. PageResources.

You should use the following code to access your key:

PageResources.ResourceManager.GetString("YourKey")



Regards  

2
12/30/2011 2:55:20 AM
647 Reputation 69 Total posts

Thank you. That works just fine as a solution for my custom strings.

3
This is a demo site for MonoX. Please visit Mono Software for more info.