Cross-Project Resource Sharing Strategy

I have a central library (DLL) called Core, which is used by many projects (some web applications, some forms of winnings, some other class libraries).

Some resources are stored in the Core library.

When I need to use the resource file in the Core library, I need to know what culture information is. Since it is sometimes used in a win form application, sometimes in a web application, I cannot use the culture from HttpContext or from CurrentThread.

I assume this is a common problem, so I'm wondering:

What is a good strategy for passing culture information around DALs and user interface projects?

+4
source share
2 answers

You can always get culture from CurrentThread. It is supported both in WinForms and in web applications. Even better: you probably won't have to worry about this at all, as the .NET resource manager will handle this based on the current culture.

+2
source

You can set ui culture for stream.

Then you are already fixed in case of WinForms.

In aspnet, you will need to set the current ui culture for the stream. You can connect this procedure to the OnActionExecuted base controller for this purpose (MVC) or use the PreInit event (web forms). This can also be done in the HttpModule.

+1
source

All Articles