Answered step by step
Verified Expert Solution
Question
1 Approved Answer
This is a C# program that suppost to display process that start up on the users pc and how long they have been open for
This is a C# program that suppost to display process that start up on the users pc and how long they have been open for but i cant seem to figure out why this error keeps poping up
- ProcessWatch + Program.cs + x Form1.cs (Design) C# ProcessWatcher ProcessWatcher.ProcessWatch 1 using System; 2 using System.Management; 3 using System.Windows.Forms; 4 5 namespace ProcessWatcher 6 { 1 reference 7 public partial class ProcessWatch : Form 8 { 9 ManagementEventWatcher processStartEvent = new ManagementEventWatcher("SELECT * FROM Win32_ProcessStartTrace"); 10 Management Eventwatcher processStopEvent = new ManagementEventwatcher("SELECT * FROM Win32_ProcessStopTrace"); 11 o references 12 public ProcessWatch() 13 { { 14 InitializeComponent(); 15 16 processStartEvent.EventArrived += new EventArrivedEventHandler(ProcessStartEvent_EventArrived); 17 processStartEvent.Start(); processStopEvent.EventArrived += new EventArrivedEventHandler(ProcessStopEvent_EventArrived); 19 processStopEvent.Start(); 20 } 21 18 1 reference - 22 23 24 25 26 27 28 29 void ProcessStartEvent_EventArrived(object sender, EventArrivedEventArgs e) { string processName = e. NewEvent.Properties["ProcessName" ].Value.ToString(); string processID = Convert.ToInt32(e.NewEvent.Properties["ProcessID"].Value).ToString(); Console.WriteLine("Process started. Name: " + processName + " | ID: " + processID); } 1 reference void ProcessStopEvent_EventArrived(object sender, EventArrivedEventArgs e) { string process Name = e. NewEvent.Properties["ProcessName"].Value.ToString(); string processID = Convert.ToInt32(e.NewEvent.Properties[ "ProcessID"].Value).ToString(); 30 31 32 33 34 35 36 37 38 Console.WriteLine("Process stopped. Name: " + processName + " | ID: " + processID); } 91 % * 1 AO Ln: 15 Ch: 13 SPC CRLF 1 x File Error List Entire Solution X 1 Error A0 Warnings A Warnings 2 Messages * Build + IntelliSense Code Description CS0103 The name 'InitializeComponent' does not exist in the current context DE0044 Make field readonly DE0044 Make field readonly Project ProcessWatcher ProcessWatcher ProcessWatcher Search Error List Line Suppression State 14 Active 9 Active Program.cs Program.cs Program.cs 10 Active Output Error ListStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started