Home > Articles > Programming > Windows Programming

This chapter is from the book

Uninstalling/Unregistering Custom Cultures

Custom cultures can be unregistered using the static CultureAndRegionInfoBuilder.Unregister method:

CultureAndRegionInfoBuilder.Unregister("en-GB");

This method attempts to undo the two steps of the Register method (it deletes the Registry key and attempts to delete the NLP file). The attempt to delete the NLP file might or might not be successful. The Unregister method looks to see if the custom culture is referenced by other custom cultures. In the process of doing so, it can open the NLP file itself and be the cause of its own failure. This is why it is possible to attempt to unregister a custom culture even after rebooting the machine and still have it fail. In this case, the Unregister method simply renames the file's extension to "tmp0" (e.g., "en-GB.tmp0"). There is no subsequent cleanup, so the temporary files remain in the Globalization folder indefinitely. This is an important point if your application registers a custom culture at startup and then unregisters as the application is shutting down. Also note that Unregister requires administrator rights.

  • + Share This
  • 🔖 Save To Your Account