I\'m using asp.net 3.5, my solution currently has 2 projects, an API class project and a website project, within the class project I have a resource file named checkin.resx.
Resource expressions (<%$ Resources: ClassKey, ResourceKey %>
) use ResourceExpressionBuilder class behind the scene. This class can lookup global and local resources only (in website's App_GlobalResources
and App_LocalResources
folders).
Instead, you can use CodeExpressionBuilder class to access resources from different project. Here's how to use it.
Add CodeExpressionBuilder class to App_Code folder:
using System.CodeDom;
using System.Web.Compilation;
using System.Web.UI;
[ExpressionPrefix("Code")]
public class CodeExpressionBuilder : ExpressionBuilder
{
public override CodeExpression GetCodeExpression(BoundPropertyEntry entry,
object parsedData, ExpressionBuilderContext context)
{
return new CodeSnippetExpression(entry.Expression);
}
}
Add the following to system.web/compilation section in web.config:
<compilation debug="false">
...
<expressionBuilders>
<add expressionPrefix="Code" type="CodeExpressionBuilder"/>
</expressionBuilders>
</compilation>
Finally, you can call into strongly-typed class generated for your .resx file:
<asp:Label ID="Label1" runat="server" Text="<%$ Code: ClassLibrary1.Resource1.String1 %>" />
Not sure if this will solve your problem but have you looked at the HttpContext.GetGlobalResourceObject method?
I've used it to access resources in the web project, from class libraries in a framework project - so perhaps you will have luck in using it the other way around.