Note: Forums will be making significant UX changes to address key usability improvements surrounding search, discoverability and navigation. To learn more about these changes please visit the announcement which can be found HERE.
File Not Found Exception will calling a method

Answered File Not Found Exception will calling a method

  • Wednesday, August 01, 2012 11:09 PM
     
      Has Code

    Hello there, I'm calling a method, and even before entering the method i receive file not exception...

    Here, I log the step before entering to the method, and i receive the result in the Event Viewer.

    ((DebugLogger)_logProviderDebugMode).Log("T1", "Debug-EventReaderClass", EventLogEntryType.Information);
                    if (RunLogParser(fromDate, toDate))
                    {

    Here's body of method, before performing any other action...

    i dont see Step T1-1 to be passed in my event viewer

    private bool RunLogParser(string startDate, string endDate)
            {
                ((DebugLogger)_logProviderDebugMode).Log("T1-1", "Debug-EventReaderClass", EventLogEntryType.Information);


    and i recieve following error with event ID of 5000:

    EventType clr20r3, P1 fileeventreaderservice.exe, P2 1.0.0.0, P3 5019a8ae, P4 fileeventreaderservice, P5 1.0.0.0, P6 5019a8ae, P7 4a, P8 124, P9 system.io.filenotfoundexception, P10 NIL.
    
    For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp.

All Replies

  • Wednesday, August 01, 2012 11:26 PM
    Moderator
     
     

    Unfortunately, we can't see the internals of your "Log" method, but it's raising this exception.

    Look at DebugLogger.Log - it, or a method called by it, is raising a FileNotFoundException.  This may be because it's trying to write to a file (which makes sense, as it's a logger), and the file can't be written or doesn't exist.


    Reed Copsey, Jr. - http://reedcopsey.com
    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".

  • Thursday, August 02, 2012 5:25 AM
     
      Has Code
    it's nothing special, and dont call any file...
    
    also i loged previous error with this ,a dn it doesnt rise any error, so i'm perfectly sure, that this class is not at fault...
    
    class DebugLogger : ILogProvider
        {
            private string Source { get; set; }
            private string LogName { get; set; }
            private bool IsWorking { get; set; }
            public DebugLogger(string source, string logName,bool isWorking)
            {
                Source = source;
                LogName = logName;
                IsWorking = isWorking;
            }
    
            [Obsolete("some extra setup that does not need for debug")]
            public bool Log(string msg, string title, EventLogEntryType type, int id, bool sendToInterface)
            {
                if(!IsWorking) return false;
                //CreateLogSourceIfNotExist(); only with administrative permissions
    
                string log = title + ": " + msg;
    
                WriteToEventLog(log, type, id);
                return false;
            }
    
            public bool Log (string msg, string title, EventLogEntryType type, int id=0)
            {
                return Log(msg, title, type, id,false);
            }
            private void WriteToEventLog(string log, EventLogEntryType type, int id)
            {
                EventLog myLog = new EventLog();
                myLog.Source = Source;
                myLog.Log = LogName;
    
                myLog.WriteEntry(log, type, id);
            }
    
            /// <summary>
            /// Need Administrative permission.
            /// Times we have only application persmission we use eventLogInstaller component instead.
            /// </summary>
            private void CreateLogSourceIfNotExist()
            {
                if (!EventLog.SourceExists(Source))
                {
                    EventLog.CreateEventSource(Source, LogName);
                }
            }
        }

  • Thursday, August 02, 2012 8:04 PM
     
     
    any answer? solution?
  • Friday, August 03, 2012 7:46 AM
     
     
    The stack trace of the exception should tell you where the exception is thrown.
  • Friday, August 03, 2012 5:00 PM
     
     
    There's a service running, how can i check for stack trace?
  • Friday, August 03, 2012 11:55 PM
     
     

    thank you man

    find it :)

    problem was with a assembly which it couldnt load, and were used in that method...

    But i''m wonder the assembly exist...

    Event Type:    Error
    Event Source:    EventLoggerService
    Event Category:    None
    Event ID:    0
    Date:        8/4/2012
    Time:        4:00:44 AM
    User:        N/A
    Computer:    HF-SERVER-PC
    Description:
    Debug-EventReaderClass: Error Msg: Could not load file or assembly 'Interop.MSUtil, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.
    StackTrace:    at FileEventReaderService.EventReader.ReadEventsAndStoreInDatabase(String startDate, String endDate)
       at FileEventReaderService.EventReader.SubtleTime_OnMinuteChanged(Object sender, EventArgs e)

    Class Variable Information:
    ---------------------------
    _logProvider: FileEventReaderService.Services.Logger.EventLogger
    _logProviderDebugMode: FileEventReaderService.Services.Logger.DebugLogger
    _licenceState: Ok
    _dataBase: deadManN
    _interval: 5
    _timeGap: 1
    _previousReadTime: 8/4/2012 3:48:43 AM
    _lastReadTime: 8/4/2012 3:59:44 AM
    _parserLock: System.Object
    _subtleTime: TimerLib.SubtleTime
    _parserService: FileEventReaderService.Services.Util.ParserService5
    _connectionStringBuilder: FileEventReaderService.Services.Util.ConnectionStringBuilder
    _lastTime: 6
    _minutes: 6

    For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp.

  • Saturday, August 04, 2012 12:36 AM
    Moderator
     
     Answered

    Interop.MSUtil is used to parse IIS log files.  I'm not sure exactly why you're code is trying to read it, but it can be missing depending on your deployment.

    For details and instructions on how to fix, see: http://stackoverflow.com/a/11203698/65358


    Reed Copsey, Jr. - http://reedcopsey.com
    If a post answers your question, please click "Mark As Answer" on that post and "Mark as Helpful".

    • Marked As Answer by deadManN Sunday, August 12, 2012 4:58 AM
    •  
  • Saturday, August 04, 2012 10:11 PM
     
      Has Code

    lol i find the same thing, but new error appeared....

    all i did, was open up command of VS 2005 because command of VS 2010 return .Net4 based DLL and i use ver 2 for some matter like old O/S'es...

    some people say that you should register the DLL, som say dont use any type while building and put it on cpu type 86x, but i look for best way to fix it! any one know?

    i process to this level...

    try
                {
                    ((DebugLogger) _logProviderDebugMode).Log("T1-2", "Debug-EventReaderClass",
                                                              EventLogEntryType.Information);
                    LogQueryClass qry = new LogQueryClass();
                    COMEventLogInputContextClass eventLogFormat = new COMEventLogInputContextClassClass();
                    ((DebugLogger) _logProviderDebugMode).Log("T1-3", "Debug-EventReaderClass",
                                                              EventLogEntryType.Information);
                    string query = "select * from security WHERE TimeGenerated >= '" + startDate +
                                   "' and TimeGenerated <'" + endDate +
                                   "' and (eventid=560 or eventid=540)";
                    rs = qry.Execute(query, eventLogFormat);
                    ((DebugLogger) _logProviderDebugMode).Log("T1-4", "Debug-EventReaderClass",
                                                              EventLogEntryType.Information);
                    for (; !rs.atEnd(); rs.moveNext())
                    {
                            //Processes
                    }
    
                }
                catch(Exception ex)
                {
                    ((DebugLogger)_logProviderDebugMode).Log(
                            "T1-5\nError Msg: " + ex.Message + "\nStackTrace: " + ex.StackTrace
                            , "Debug-EventReaderClass",
                            EventLogEntryType.Error);
                }
                finally
                {
                    ((DebugLogger)_logProviderDebugMode).Log("T1-6", "Debug-EventReaderClass",
                                                              EventLogEntryType.Information);
                    if (rs != null)
                        rs.close();
                }

    And i recieve Exception...

    also i have nothing in my processes which mean my query was empty :|

    Event Type:	Error
    Event Source:	EventLoggerService
    Event Category:	None
    Event ID:	0
    Date:		8/5/2012
    Time:		2:35:10 AM
    User:		N/A
    Computer:	HF-SERVER-PC
    Description:
    Debug-EventReaderClass: T1-5
    Error Msg: Retrieving the COM class factory for component with CLSID {8CFEBA94-3FC2-45CA-B9A5-9EDACF704F66} failed due to the following error: 80040154.
    StackTrace:    at FileEventReaderService.EventReader.ReadEventsAndStoreInDatabase(String startDate, String endDate)
    
    Class Variable Information:
    ---------------------------
    _logProvider: FileEventReaderService.Services.Logger.EventLogger
    _logProviderDebugMode: FileEventReaderService.Services.Logger.DebugLogger
    _licenceState: Ok
    _dataBase: deadManN
    _interval: 5
    _timeGap: 1
    _previousReadTime: 8/5/2012 2:23:00 AM
    _lastReadTime: 8/5/2012 2:34:01 AM
    _parserLock: System.Object
    _subtleTime: TimerLib.SubtleTime
    _parserService: FileEventReaderService.Services.Util.ParserService5
    _connectionStringBuilder: FileEventReaderService.Services.Util.ConnectionStringBuilder
    _lastTime: 6
    _minutes: 6
    
    For more information, see Help and Support Center at http://go.microsoft.com/fwlink/events.asp.
    

  • Sunday, August 05, 2012 6:54 AM
     
     
    any help?
  • Monday, August 06, 2012 1:35 AM
     
     
    i also log some of my process and images in here:
    http://stackoverflow.com/questions/11814752/assembly-issue-with-logparserdll-which-i-convert-to-interop-msutil-using-tblim

    if it help :'(
  • Sunday, August 12, 2012 4:57 AM
     
     Answered
    other error and exception solved, so i write the asnwer in here, if any one required:
    http://stackoverflow.com/a/11919815/1260751
    • Marked As Answer by deadManN Sunday, August 12, 2012 4:58 AM
    •