Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Instruct CodeDomProvider compiler to show errors and warning messages in English language?

Tags:

I'm using the System.CodeDom features to compile code at run time and I wonder if I could specify a compiler parameter or other workaround to display the compiler errors in English language instead of using the system's default language.

However, in the MSDN documentation I can't find anything related to the displayed language:

  • VB.Net compiler params
  • C# compiler params

When I want to display compiler errors in a specific language under Visual Studio IDE when building a project what I do is change the current culture, then I tried to set the culture in my application and also inside the file that I'm compiling from my application, but firstly that does not take effect, and secondly I prefer to avoid possible tricks like this, because possibly it will require automated code generation (imports, references, and code when calling CodeDomProvider compiler):

Thread.CurrentThread.CurrentCulture = New CultureInfo("en-Us") Thread.CurrentThread.CurrentUICulture = New CultureInfo("en-Us") 
like image 860
ElektroStudios Avatar asked Sep 19 '15 12:09

ElektroStudios


1 Answers

You probably should use CompilerParameters.CompilerOptions property. If you open link you may find example there. You need to change preferreduilang parameter. To set output language to English use "/preferreduilang:en-US" option. Keep in mind that it would not work for languages which are not installed in your system.

like image 124
Alexander Levinson Avatar answered Sep 27 '22 19:09

Alexander Levinson