Click here to Skip to main content
15,887,350 members
Home / Discussions / C#
   

C#

 
QuestionPorting VS 2005 => 2010: "Could not load file or assembly..." [SOLVED] Pin
Alan Balkany8-Dec-11 12:14
Alan Balkany8-Dec-11 12:14 
AnswerRe: Porting VS 2005 => 2010: "Could not load file or assembly..." Pin
Richard MacCutchan8-Dec-11 22:22
mveRichard MacCutchan8-Dec-11 22:22 
GeneralRe: Porting VS 2005 => 2010: "Could not load file or assembly..." Pin
Alan Balkany9-Dec-11 4:55
Alan Balkany9-Dec-11 4:55 
GeneralRe: Porting VS 2005 => 2010: "Could not load file or assembly..." Pin
Richard MacCutchan9-Dec-11 6:20
mveRichard MacCutchan9-Dec-11 6:20 
GeneralRe: Porting VS 2005 => 2010: "Could not load file or assembly..." Pin
Alan Balkany9-Dec-11 7:12
Alan Balkany9-Dec-11 7:12 
AnswerLink to solution Pin
Alan Balkany12-Dec-11 5:25
Alan Balkany12-Dec-11 5:25 
Questioncontrol "asp:listview" bind to web service without database with "if statement" c# Pin
aspkiddy8-Dec-11 10:26
aspkiddy8-Dec-11 10:26 
Questionproblem with list predicate (?) or list item not being found Pin
CCodeNewbie8-Dec-11 9:33
CCodeNewbie8-Dec-11 9:33 
Hi all,

I seem to be having a problem with value validation of a list in a foreach loop and was wondering if you could please point out where the logic/syntactic error is?

Basically I am enumerating the Windows Application log for an eventid value then for a timewritten value. If the value is not found the code should run. If the value is found but is older than 1 hour then the code should run. If the value is found and is not 1 hour old then the code should not run. This is what I have but the code runs on my 2-minute timer anyway indicating that the value is not being found (I think)
C#
public void OnTimedEvent(object source, ElapsedEventArgs e)
        {
int run;
run = 0;
EventLog eLog = new EventLog("Application");
foreach (EventLogEntry entry in eLog.Entries)
   {
   if (entry.EventID == 13162)// if entry.EventID <> 13162 then run
      {
      List<int> evid = new List<int>();
      evid.Add(entry.EventID);
      foreach (int IDNo in evid)
        {
        if (entry.TimeWritten > DateTime.Now.AddHours(-1))// then run
            {
                run = 1;
            }
            else run = 2;
        }
    }
}
if(run == 0 ||run ==  1)
   {
      //do stuff
   }
if (!EventLog.SourceExists("mylog")) EventLog.CreateEventSource("mylog", "Application");
EventLog.WriteEntry("mylog", "code has run", EventLogEntryType.Information, 13162);
}// write the event ID so that the next execution of the foreach loop picks up the value and doesn't run until the value's timewritten is older than 1 hour


This has been driving me nuts for nearly 3 days now and I just can't figure it out. I have tried evid.contains and evid.find methods but either the //do stuff won't run at all or it keeps running on the timedevent, i.e. every 2 minutes. Could you help please?
AnswerRe: problem with list predicate (?) or list item not being found Pin
emardini8-Dec-11 15:00
emardini8-Dec-11 15:00 
GeneralRe: problem with list predicate (?) or list item not being found Pin
CCodeNewbie8-Dec-11 21:38
CCodeNewbie8-Dec-11 21:38 
QuestionC# dataset error Pin
classy_dog8-Dec-11 9:05
classy_dog8-Dec-11 9:05 
QuestionLinq - Remove Object From Collection Pin
Kevin Marois8-Dec-11 7:19
professionalKevin Marois8-Dec-11 7:19 
AnswerRe: Linq - Remove Object From Collection Pin
fjdiewornncalwe8-Dec-11 7:37
professionalfjdiewornncalwe8-Dec-11 7:37 
AnswerRe: Linq - Remove Object From Collection Pin
Dan Mos8-Dec-11 7:46
Dan Mos8-Dec-11 7:46 
GeneralRe: Linq - Remove Object From Collection Pin
Kevin Marois8-Dec-11 7:49
professionalKevin Marois8-Dec-11 7:49 
GeneralRe: Linq - Remove Object From Collection Pin
Dan Mos8-Dec-11 7:56
Dan Mos8-Dec-11 7:56 
GeneralRe: Linq - Remove Object From Collection Pin
Kevin Marois8-Dec-11 7:57
professionalKevin Marois8-Dec-11 7:57 
GeneralRe: Linq - Remove Object From Collection Pin
Dan Mos8-Dec-11 8:22
Dan Mos8-Dec-11 8:22 
GeneralRe: Linq - Remove Object From Collection Pin
Kevin Marois8-Dec-11 8:24
professionalKevin Marois8-Dec-11 8:24 
GeneralRe: Linq - Remove Object From Collection Pin
Dan Mos8-Dec-11 9:18
Dan Mos8-Dec-11 9:18 
GeneralRe: Linq - Remove Object From Collection Pin
BobJanova8-Dec-11 22:44
BobJanova8-Dec-11 22:44 
Generaltwo compile time errors with your for loop based code: Re: Linq - Remove Object From Collection Pin
BillWoodruff9-Dec-11 9:16
professionalBillWoodruff9-Dec-11 9:16 
GeneralRe: Linq - Remove Object From Collection Pin
BillWoodruff9-Dec-11 9:17
professionalBillWoodruff9-Dec-11 9:17 
AnswerRe: Linq - Remove Object From Collection Pin
Mirko198012-Dec-11 2:53
Mirko198012-Dec-11 2:53 
AnswerRe: Linq - Remove Object From Collection Pin
BillWoodruff9-Dec-11 1:04
professionalBillWoodruff9-Dec-11 1:04 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.