[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

URGENT HELP NEEDED.....Errors in 'System.Diagnostics.EventLog.WriteEntry & 'System.Diagnostics.EventLogEntryType'

Posted on 2004-10-26
1
Medium Priority
?
1,084 Views
Last Modified: 2007-12-19
error CS1502: The best overloaded method match for 'System.Diagnostics.EventLog.WriteEntry(string, string, System.Diagnostics.EventLogEntryType)' has some invalid arguments
error CS1503: Argument '3': cannot convert from 'string' to 'System.Diagnostics.EventLogEntryType'
error CS1502: The best overloaded method match for 'System.Diagnostics.EventLog.WriteEntry(string, string, System.Diagnostics.EventLogEntryType)' has some invalid arguments
error CS1503: Argument '3': cannot convert from 'string' to 'System.Diagnostics.EventLogEntryType'

What can I do to fix the error with the sData. I need to have the original message string be posted into the errorlog.


     private void ReceiveData(Byte [] byteBuffer, int size)
      {
         string sData = Encoding.ASCII.GetString(byteBuffer,0, size);
         
        // Initializes the variables to pass to the MessageBox.Show method.
         string errMsg = "Disk Failure".PadLeft(300, ' ').PadRight(300, ' ');

         try
         {
            if((sData.ToLower().IndexOf("disk") > -1) &&
               (sData.ToLower().IndexOf("failed") > -1))
            {
               System.Diagnostics.EventLog.WriteEntry(this.ToString(),
               "Failure Msg received", sData);   ****ERROR IS HERE WITH sDATA****

               // Displays the MessageBox.

                  MessageBox.Show(errMsg, "WARNING!!", MessageBoxButtons.OK,
                  MessageBoxIcon.Error, MessageBoxDefaultButton.Button1,
                  MessageBoxOptions.ServiceNotification);

            }

            else if((sData.ToLower().IndexOf("disk") > -1) &&
               (sData.ToLower().IndexOf("rebuilding") > -1) &&
               (sData.ToLower().IndexOf("successfully") > -1))
            {
               // post the message in the error log
               System.Diagnostics.EventLog.WriteEntry(this.ToString(),
               "Rebuild Msg Received", sData);  ****ERROR IS HERE WITH sDATA****
            }

            else
               System.Diagnostics.EventLog.WriteEntry(this.ToString(),
                  "EventListener, Can't process data" + "::Stopped");
         }

         catch(InvalidCastException e)
         {
            System.Diagnostics.EventLog.WriteEntry(this.ToString(),
               "InvalidCast Error #");
         }

      }
0
Comment
Question by:NewMom2Brandon
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 2

Accepted Solution

by:
pdrau earned 2000 total points
ID: 12412577
You are trying to use EventLog.WriteEntry Method (String, String, EventLogEntryType)

The EventLogEntry Type should not be a string and therefore is causing the error.

Here's part an example found in EventLogEntryType Enumeration entry in Visual Studio.NET help.

switch( myIntLog )
{
   case 1:
      // Write an 'Error' entry in specified log of event log.
      myEventLog.WriteEntry( myMessage, EventLogEntryType.Error, myID );
      break;
   case 2:
      // Write a 'Warning' entry in specified log of event log.
      myEventLog.WriteEntry( myMessage, EventLogEntryType.Warning, myID );
      break;
   case 3:
      // Write an 'Information' entry in specified log of event log.
      myEventLog.WriteEntry( myMessage, EventLogEntryType.Information, myID );
      break;
   case 4:
      // Write a 'FailureAudit' entry in specified log of event log.
      myEventLog.WriteEntry( myMessage, EventLogEntryType.FailureAudit, myID );
      break;
   case 5:
      // Write a 'SuccessAudit' entry in specified log of event log.
      myEventLog.WriteEntry( myMessage, EventLogEntryType.SuccessAudit, myID );
      break;
   default:
      Console.WriteLine("Error: Failed to create an event in event log.");
     break;
}


Your code:

 // post the message in the error log
               System.Diagnostics.EventLog.WriteEntry(this.ToString(),
               "Rebuild Msg Received", sData);  ****ERROR IS HERE WITH sDATA****

The sData value needs to be EventLogEntryType.OneOfTheValidTypes

The valid type members:

Member name Description
Error                An error event. This indicates a significant problem the user should know about; usually a loss of functionality or data.
FailureAudit      A failure audit event. This indicates a security event that occurs when an audited access attempt fails; for example, a failed attempt to open a file.
Information       An information event. This indicates a significant, successful operation.
SuccessAudit     A success audit event. This indicates a security event that occurs when an audited access attempt is successful; for example, logging on successfully.
Warning            A warning event. This indicates a problem that is not immediately significant, but that may signify conditions that could cause future problems.


Hope this helps resolve your question.
0

Featured Post

What’s Wrong with Your Cloud Strategy ?

Even as many CIOs are embracing a cloud-first strategy, the reality is that moving to the cloud is a lengthy process and the end-state is likely to be a blend of multiple clouds—public and private. Learn why multicloud solutions matter in this webinar by Nimble Storage.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A short article about problems I had with the new location API and permissions in Marshmallow
This article will inform Clients about common and important expectations from the freelancers (Experts) who are looking at your Gig.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
Six Sigma Control Plans

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question