none
ProviderMetadata always returns message in en-US format RRS feed

  • Question

  • Hi team,

    I am working with ProviderMetadata class has method

    ProviderMetadata metaData = new ProviderMetadata(providerName, session, CultureInfo.CurrentCulture); 

    (Contains static information about an event provider, such as the name and id of the provider, and the collection of events defined in the provider).When i use this method this returns always in english.

    My machine Language is : Chinesse - Simplified language

    This is my code

      public static void providerMetaData()
            {
                try
                {
                    SecureString pw = GetPassword();
                    EventLogSession session = new EventLogSession(
                        "cn-dc1",                               // Remote Computer
                        "test",                                  // Domain
                        "administrator",                                // Username
                        pw,
                        SessionAuthentication.Default);

                    pw.Dispose();
                    Thread.CurrentThread.CurrentCulture = new CultureInfo("zh-Hans");
                    string providerName = "Microsoft-Windows-Security-Auditing";
                    ProviderMetadata metaData = new ProviderMetadata(providerName, session, CultureInfo.CurrentCulture  //Provider name to look up
                                           );         //Culture of active thread


                    if (null != metaData)
                    {
                        Console.WriteLine(metaData.DisplayName);             //Display Name of the provider                    
                        Console.WriteLine(metaData.HelpLink.ToString());    //Link to external help on event
                        Console.WriteLine(metaData.MessageFilePath);     //Source of provider metadata
                        Console.WriteLine(metaData.ResourceFilePath);   //Resource with provider metadata
                    }

                    Console.WriteLine("This provider publishes the following events:");
                    foreach (EventMetadata eventData in metaData.Events)
                    {
                        Console.WriteLine("--------------------------------------------------");
                        Console.WriteLine("Event ID = {0}. Description: {1}", eventData.Id, eventData.Description);
                    }
                }
                catch (Exception ex)
                {
                    //Logger.Event.ErrorFormat("EXCEPTION :: WindowsEventLog.providerMetaData :\n{0}", ex);
                }
            }

    Thanks in Advance

    Thursday, February 15, 2018 1:31 PM

All replies

  • Hi Balakumar Smart,

    Thank you for posting here.

    For your question, what is the .net framework version of your project?

    In your code, you used Thread.CurrentThread.CurrentCulture Method to set the current culture. 

    But in the .NET Framework 4.5.2 and earlier versions, the CurrentCulture property is read-only; that is, you can retrieve the property value, but you cannot set it. Starting with the .NET Framework 4.6, the CurrentCulture property is read-write; you can both set and retrieve the property's value.

    Please set the .net framework version to 4.6 and above to use the Thread.CurrentThread.CurrentCulture Method to set the current culture.

    Best Regards,

    Wendy


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.



    Wednesday, February 21, 2018 2:26 AM
    Moderator
  • Hai

    I am using 4.6.2 .Net version . I can set Thread.CurrentThread.CurrentCulture in my program.The response in English format.

    Wednesday, March 7, 2018 6:04 AM