External Project Resource (RESX) Consumption

Using resource files can sometimes be troublesome when you need a particular resource in both a Web application mark-up or code-behind and inside a business tier or data model. When you push the Resx file further back into you’re project, you’ll likely need to create it as an embedded resource for easy entry. From there you can quite simply access that resource in any code (as long as you’re referencing the project containing the resx file), as follows:


You can of course add a “using” statement and remove the Namespace from it. You can also use this in an .aspx or .ascx markup file:

<%= Namespace.ResourceFileName.ResourceManager.GetString(“ResxItemName“); %>

When using in markup, you can also add a Namespace Import and reference without the Namespace prefix:

<%@ Import Namespace=”Namespace” %>

<%= ResourceFileName.ResourceManager.GetString(“ResxItemName“); %>

In some cases, it may make sense to create yourself an entire Class Library Project purely devoted to storing all your Resource files. Then you can simply use that reference anywhere you need it without worrying about circular dependencies.