"Resource lookup failed - infinite recursion detected" and Custom Cultures

G

GB

All,

I raised a problem a while ago about custom cultures in .NET and an
error whereby a "Resource lookup failed - infinite recursion detected"
exception was raised. Usually this was raised when the custom culture
was in use and the application domain was restarted.

Anyway, there was nothing on usenet about a solution but eventually I
came across one (well, MS provided it themselves when I challenged them
about this).

In some situations the localisation plumbing uses the class hash code
behind the scenes. If your custom culture class is not overridding this
then the .NET framework can get confused as the custom culture class
looks identical to its parent (in my case my custom welsh object looked
identical to its parent en-GB object). Override the hash code in the
custom object;

public override int GetHashCode()
{
return (this.Name.GetHashCode());
}

Hey, presto... problem solved.
Cheers.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top