CodeVerge.Net Beta
Login Idy
Register Password
  Forgot?
Explore    Item Entry    Members   
NEWSGROUP
.NET
Algorithms-Data Structures
Asp.Net
C Plus Plus
CSharp
Database
HTML
Javascript
Linq
Other
Regular Expressions
VB.Net
XML





Zone: > NEWSGROUP > Asp.Net Forum > visual_studio.vs_2005_web_application_projects Tags:
Item Type: NewsGroup Date Entered: 5/10/2006 1:12:02 AM Date Modified: Subscribers: 0 Subscribe Alert
Rate It:
(NR, 0)
XPoints: N/A Replies: 7 Views: 5 Favorited: 0 Favorite
Can Reply:  No Members Can Edit: No Online: Yes
8 Items, 1 Pages 1 |< << Go >> >|
Chandra577
Asp.Net User
How to access value from Resource file in App_GlobalResources directory?5/10/2006 1:12:02 AM

0/0

Hello,

             I have seen the latest update in WAP 1.0v that "Resource support with the App_GlobalResources directory:" feature is available now, but i don't know how to access the value from the resource file using the Proxy object?

For e.g : 'Constants.resx' resource file is created under 'App_GlobalResources' folder., So to access a value(HeaderMsg) from the resource file in a sample.aspx.cs code behind page would be like

string temp = Constants.HeaderMsg; or

string temp = Namespace.App_GlobalResources.Constants.HeaderMsg(using this syntax runs into runtime error saying an exception type of"'System.Resources.MissingManifestResourceException'  occured..

It would be really helpful, if someone helps me out?

Also, I assume 'Build Action' property value for 'Constants.resx' file to 'None' would help me to make any changes in the resource file without recompiling the application - Please correct me , if I am wrong.

Thanks,

Chandra

 

 

 

timmcb
Asp.Net User
Re: How to access value from Resource file in App_GlobalResources directory?5/10/2006 4:39:12 PM

0/0

The syntax is the following:

string temp = Resources.Constants.HeaderMsg;

For resources in the App_GlobalResources directory the BuildAction should be "Content" and the CustomTool should be "GlobalResourceProxyGenerator".

You can make chages to the .resx files without recompiling.  However, if you remove or rename a resource the application could break at run-time.

Changes to constants.resx within VS will cause constants.designer.cs proxy class to update.  This will make the IDE recompile even though it may not be absolutely necessary.

Changes to constants.resx outside VS will not allow the constants.designer.cs proxy class to update.  As I stated before this is ok as long as you do not remove or rename a resource that the web app is using. It also means that if you switch back to VS intellisense will not reflect your changes.  To fix this right-click on constants.resx and "Run CustomTool."


Tim McBride

This posting is provided "AS IS" with no warranties, and confers no rights.
Chandra577
Asp.Net User
Re: How to access value from Resource file in App_GlobalResources directory?5/10/2006 8:10:27 PM

0/0

Thanks Tim. It works fine.

BTW, What would be your suggestion, If I want to add a resource file to a "Class library" project and make use of the 'Strongly typed' proxy object to refer values from the resource file?

Should I apply the same settings on resource file(BuildAction should be "Content" and the CustomTool should be "GlobalResourceProxyGenerator) ? or ??

Thanks in advance for your help!

Chandra

timmcb
Asp.Net User
Re: How to access value from Resource file in App_GlobalResources directory?5/10/2006 8:40:54 PM

0/0

TheGlobalResourceProxyGenerator was only designed to work with App_GlobalResources.  I don't think it would work with a client library.

When you add a .resx file to a Web Application Project outside of App_GlobalResources or App_LocalResources we treat it just like a client library. The BuildAction is set to EmbeddedResource and the CustomTool is set to ResXFileCodeGenerator.  The ResXFileCodeGenerator creates a strongly typed class for accessing the resource.  However, the class is internal.  This means that within the client library that contains the .resx you can access the resource strongly typed but not from a referencing assembly.

One way you can work around this is to use a different generator that creates a public class.  One exame of this is here: http://www.codeproject.com/useritems/ResXFileCodeGeneratorEx.asp.  Using this generator in your client library you should be able to access the resources in any project referencing it.  Note, there could be conflict with the resource namespaces that would have to be resolved with this approach.


Tim McBride

This posting is provided "AS IS" with no warranties, and confers no rights.
Grimolfr
Asp.Net User
Re: How to access value from Resource file in App_GlobalResources directory?8/3/2006 7:56:38 PM

0/0

There still seems to be a bug with the GlobalResourceProxyGenerator tool in WAP.

It works fine for strings, but if you try to use text file resources, the tool is looking for the resource files in the VS2k5 installation path instead of in the project folders.  (It looks like it's using a relative path from the project file, but it's being incorrectly resolved from either the VS executable or the DLL that the tool resides in.)

I haven't tried icons, images, etc.  I haven't had a need for them in WAP projects.

I was able to work around my immediate problem by switching to the ResXFileCodeGenerator and not use the App_GlobalResources folder, but it's still something that should be looked into.


Grim

(aka Toby)

MCSD, MCDBA, MCP+SB
timmcb
Asp.Net User
Re: How to access value from Resource file in App_GlobalResources directory?8/3/2006 11:41:05 PM

0/0

Thanks for the report.  I'll check it out.
Tim McBride

This posting is provided "AS IS" with no warranties, and confers no rights.
NoFrills44
Asp.Net User
Re: How to access value from Resource file in App_GlobalResources directory?2/20/2007 12:22:53 AM

0/0

Hi,

Is there a hot fix or patch available to fix this bug? Service pack 1 vs still has not addressed the problem.

Thanks

Rinze
Asp.Net User
Re: How to access value from Resource file in App_GlobalResources directory?8/22/2007 2:09:03 PM

0/0

I am experiencing the same problem. Is there a hotfix fore this? It appears that the path of the first file resource in a .resx file is not processed properly.

 thanx,

rinze


Hope this helps !
Rinze

---------
please select 'mark as answer' if this post helped you!
8 Items, 1 Pages 1 |< << Go >> >|



Search This Site:


Meet Our Sponsors:



Other Resources:

Uploading a resx file - advanced_asp.net.localization - Web Programming ... access a global resource from code behind. Zone: ... Items are stored in a ResX file as a Name,Value pair. ... Upload file. Special pages. ...
Invalid characters in ClientDataSet XMLData - borland.public.delphi ... Invalid characters in ClientDataSet XMLData, > ROOT > NEWSGROUP > Borland Forums > ... how to access value from resource file in app_globalresources directory? ...
How to localize Silverlight 2.0 : The Official Microsoft Silverlight Site ... how to store Labels etc in resource files and use them to change the ... back through in one past add the text to the resource file and bind everything. ...
How To: Perform a Security Deployment Review for ASP.NET 2.0 ... files; the maximum allowed value is 4096 KB: <httpRuntime maxRequestLength="file Size in KB" ... access is limited to the application's virtual directory ...
TheMSsForum.com >> Dotnet >> How to Draw Checkbox in ListView OwnerDraw ... ... the application, we just get a HTTP Error 404 - File or directory not ... using resource files resides in the global resources folder (App_GlobalResources) ...
Virtualizing Access to Content: Serving Your Web Site from a ZIP File ... provider should return a Boolean value or, in the case of ... Returns an IEnumerable instance to enumerate all of the virtual files of the virtual directory. ...
TheMSsForum.com >> Asp >> How to get the last page - The Microsoft ... Pre Selecting CheckBoxList I have some boolean value(1 or 0 ) in a table and i ... me know how to read SessionState setting from the Web.Config file into an ASPNET ...
Resources and Localization in ASP.NET 2.0 - 123aspx.com ASP.NET ... ... that you place the new resource file in the App_GlobalResources directory. Click Yes. ... named strings to a local resource file, you can access them from ...


 
All Times Are GMT