I have been developing an application in classic ASP.NET and deploying it to azure. Until now, no problem at all. Now I want to add localized resources to support multi-language.
The App_GlobalResources/*.resources files works fine when running local, both outside and inside the azure emulator. But when I try to use them in Azure, I'm getting the following error:
Could not find any resources appropriate for the specified culture (or
the neutral culture) on disk. baseName:
SistemaRRHH.Signup.SignupLabels locationInfo: fileName:
SistemaRRHH.Signup.SignupLabels.resources.
The exception is very self-explanatory, buy I can't solve it in any way.
The exception is thrown here:
var requestCultureInfo = new CultureInfo(Utils.GetRequestFirstLanguageAccepted(Request.Headers["Accept-Language"]));
ResourceManager rm = ResourceManager.CreateFileBasedResourceManager(Constants.RESOURCE_FILE_LABELS_NAME, HttpContext.Current.Server.MapPath(Constants.RESOURCE_FILE_DIRECTORY), null);
letsGetItStartedLabel.Text = rm.GetString(Constants.LETS_GET_IT_STARTED_LABEL, requestCultureInfo);
Thanks a lot for your help!
I've noticed some localisation issues within Azure, specifically with DateTimes (the usual culprit) - are you based outside of the US? We're based in the UK and using a European Data Centre but still getting US-formatted dates within Azure. If that is the case, you could try creating en-US resource files as well to see if that fixes the issue. We added a globalization tag into the web.Config for now - a short term fix but gets past the issue until I can revisit.
Related
I have a strange issue occurring on my Windows 8 dev box. The following line of code results in two different values for the NumberFormat.NumberDecimalSeparator when comparing an ASP .NET application running Kentico and a console application (both running on .NET 4.0).
var culture = new System.Globalization.CultureInfo("en-ZA");
var separator = culture.NumberFormat.NumberDecimalSeparator;
The value of seperator:
Kentico application: "," <- comma
Console application: "." <- period
The correct output for my regional setting is a period.
How is this possible? When I first picked up a formatting issue for decimal numbers, I thought it may have been a Kentico bug, however this test indicates otherwise. How is it possible that a new instance of CultureInfo for a specific locale returns an instance that differs across applications?
Jason Evans's comment pointed me in the right direction. See the link he posted: ASP.NET application doesn't reflect Regional settings
It turns out that regional settings are stored per user in Windows. This is something I should have been aware of. Updating the application pool to run as myself produced the same result across both applications.
To be fair, what is still confusing is how Network Service (the account the application pool was running under) came to have the incorrect value. I'm not even sure how I'd rectify that.
Edit:
If you need to update the regional settings for reserved accounts. You have two options.
Control Panel > Regional Settings > Click the administrative tab and then select "Copy Settings". On the screen that launches, ensure you check "Welcome Screen and system accounts". Older versions of Windows are similar I believe.
For the brave. Registry: HKEY_USERS > SID... > Control Panel > International. The security identifier for Network Service is: SID: S-1-5-20.
Ensure you restart the application pool for settings to take effect.
EDIT: Note that this wasn't the issue - but in other cases it could be, so I'm leaving it here for posterity.
I strongly suspect that the console application isn't running on .NET 4.0. It's easy enough to verify that using Environment.Version though. Here's a short console app and results via two different versions of the framework:
using System;
using System.Globalization;
class Test
{
static void Main()
{
CultureInfo culture = new System.Globalization.CultureInfo("en-ZA");
string separator = culture.NumberFormat.NumberDecimalSeparator;
Console.WriteLine("Version: {0}", Environment.Version);
Console.WriteLine("Separator: {0}", separator);
}
}
Compiling against .NET 4.5:
Version: 4.0.30319.18010
Separator: ,
Compiling against .NET 2.0:
Version: 2.0.50727.6400
Separator: .
Try this code in both applications, and see what versions they're running.
I have a classic ASP application written many years ago that I'm trying to fix.
The following lines recently stopped working after w7 sp1 was applied.
set address = Server.CreateObject("ADOR.Recordset")
count = lo_connection.GetRecordset(sql,address,false, error)
Set RDF2 = Server.CreateObject("RDSServer.DataFactory")
Set teststring = RDF2.ConvertToString(address)
It fails on the last line there saying "Microsoft VBScript runtime error: Class doesn't support Automation"
A bit of searching found several articles like this one
http://blogs.technet.com/b/asiasupp/archive/2011/03/14/changes-in-mdac-adodb-com-components-in-windows-7-service-pack-1.aspx
that described the problem exactly. Where I am failing is that none of the suggested fixes seems to fix the problem. Any suggestions?
The solutions described in the link are not relevant here, since ASP is not early-bound - it uses OLE Automation. It might be worth re-registering the component which creates RDSServer.DataFactory objects (which is C:\Program Files\Common Files\system\msadc\msadcf.dll on my machines).
I looked up this object, and I found this Microsoft web page:
http://msdn.microsoft.com/en-us/library/windows/desktop/ms681447(v=vs.85).aspx
"This feature will be removed in a future version of Windows. Avoid using this feature in new development work, and plan to modify applications that currently use this feature. Applications that use RDS should migrate to WCF Data Service."
Doesn't sound too good.
UPDATE : is there any iis 7 setting which might cause this issue? I recently moved to iis 7.0.
So I am having this weird issue where my code works locally but not when i deploy it live.
For example -
Employee e= new Employee();//does work locally
Employee e= new Employee(); // does not work live..says cannot convert Employee to MyLibrary.Model.Employee
MyLibrary.Model.Employee e= new MyLibrary.Model.Employee();////works live
So for some reason from the above code you can see it is not basically finding my using statements in the file.Although I have them it asks me to declares its full qualified name. Does anyone know what is happening?
The only time I have seen problems like this when dealing with ASP.net is when a stale assembly has been cached.
You probably don't have MyLibrary.Model.dll referenced in the live build.
Do you have two different assemblies referenced that both define an "Employee" object?
If so, you will need to fully qualify the objects.
I have installed NHibernate for my ASP.NET web app although I'm getting a problem in real-time on the following line of code:
if (_sessionFactory == null)
{
_sessionFactory = new Configuration().Configure().BuildSessionFactory();
}
Looking at the inner exception the problem is this:
{"Could not find file 'D:\Websites\Test\Test\Test\bin\hibernate.cfg.xml'.":"D:\Websites\Test\Test\Test\bin\hibernate.cfg.xml"}
This makes sense, as the file doesnt exist in that location. This line of code is within my Core project. File hibernate.cfg.xml is currently in my Infrastucture project, not my Core. Should this be? I have copied the file into this location although I still get problems. If I manually copy the file into this location within windows explorer I then get the following error during runtime.
{"Could not load file or assembly
'Infrastructure' or one of its
dependencies. The system cannot find
the file specified.":"Infrastructure"}
Also, I'm missing DynamicProxy.dll as I'm using castle and I couldnt see a version of the DynamicProxy in the castle folder that I downloaded from http://sourceforge.net/projects/nhibernate/
any suggestions? I can see LinFu.DynamicProxy.dll within the download although it says I only need one of the folders, Linfu or Castle, and I'm using Castle for this experiment. Not sure if this has anything to do with it, just thought it might help.
any ideas? Many thanks,
James
About "Could not find hibernate.cfg.xml": you can either set it to "Copy to Output" (see this) or configure it as an embedded resource.
About "Could not load assembly Infrastructure": you're missing Infrastructure.dll in your bin, or one of its dependencies, just as the error says.
About missing DynamicProxy.dll: if you're using NHibernate 3.x all you need to use the Castle bytecode provider is NHibernate.ByteCode.Castle.dll and Castle.Core.dll
I am having an issue when attempting to override the DisplayNameAttribute in ASP.NET MVC to provide a localized string. The code itself is straightforward and similar to that in another Stackoverflow post link text
The code works for global resources but not so well for local resources. I have a registration screen and used the Visual Studio "Generate Local Resource" command to create my local resource file. The generated file is named Registration.aspx.resx and the App_LocalResources folder is created relative to the actual Registration.aspx page - as one would expect.
However, when I attempt to get the localized string using:
ResourceManager.GetString(resourceKey)
I receive the following error message.
Could not find any resources
appropriate for the specified culture
or the neutral culture. Make sure
"FullAssemblyName.Views.Account.App_LocalResources.Registration_aspx.resources"
was correctly embedded or linked into
assembly "FullAssemblyName" at compile
time, or that all the satellite
assemblies required are loadable and
fully signed.
Using reflector, I can see that the file is actually Registration.aspx.resources and not Registration_aspx.resources - the underscore/period being the subtle difference
FullAssemblyName.Views.Account.App_LocalResources.Registration.aspx.resources
I have toyed with the code quite a bit but no matter what I do, the file being requested is always different than that copiled in the assembly. For instance, if i rename Registration_aspx (in the generated Registration.aspx.designer.cs class i get the same error but this time the path is "...App_LocalResources.Registrationaspx.resources"
Has anyone run into this? Is there any way I can ensure that the resource found in my assembly has this underscore?!?!?
Thank you in advance!
Try Michael K. Campbell solution link text. It worked fine form me in localizing my project.