开发者

System.IO.FileNotFoundException occurs after call to DirectoryEntry()

I am debugging a small C# app that I just wrote. The app seems to run fine on my development box but throws the following errors when run on other machines (all machines are windows 7 pro x64 w/ .net 4 installed):

    Application: WolApp.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.IO.FileNotFoundException
Stack:
   at WolApp.PowerModel..ctor()
   at WolApp.PowerController..ctor()
   at WolApp.Program.Main()

A second error succeeds this one from kernelbase.dll, but, one thing at a time....

From the stack trace it seems that the unhandled exception is being throwin inside of the PowerMod开发者_如何学Goel constructor, which consists only of this:

public PowerModel() {
entry = new DirectoryEntry();
}

Where entry is a field of the PowerModel class. I have since added the following try catch block

 public PowerModel() {
            try
            {
                entry = new DirectoryEntry();
            }
            catch (System.IO.FileNotFoundException e)
            {
                string sSource;
                string sLog;
                string sEvent;

                sSource = "WolApp";
                sLog = "Application";
                sEvent = e.Message;
                EventLog.CreateEventSource(sSource,sLog);
                EventLog.WriteEntry(sSource, sEvent);
             }
        }

Yet the same exception is still thrown (and only on external machines)?

Also, an additional message appears in the log from Windows Error Reporting, as follows:

 1745074215 
   5 
   CLR20r3 
   Not available 
   0 
   wolapp.exe 
   1.0.0.0 
   4d657be0 
   WolApp 
   1.0.0.0 
   4d657be0 
   3 
   26 
   System.IO.FileNotFoundException 

   C:\Users\username\AppData\Local\Temp\WERC3EF.tmp.WERInternalMetadata.xml 
   C:\Users\username\AppData\Local\Microsoft\Windows\WER\ReportArchive\AppCrash_wolapp.exe_62bdee217c82fa90fcdaeb137c1659c897785b85_20036868 

   0 
   ce7dc05c-3f93-11e0-8907-0024e82e58f8 
   0 


DirectoryEntry is a class from the System.DirectoryServices namespace and deals with entries in an Active Directory.

It has nothing whatsoever to do with an entry in the directory on disk ... I am most surprised you would get a FileNotFoundExeption with this...

(not applicable) Or if it's not the System.DirectoryServices.DirectoryEntry you're talking about, then it's an extremely bad choice of a class name for this class!


I have not seen this issue, but something similar appears here on MSDN, with a fix.

EDIT I just re-read your error message, and this bit jumped out:

CLR20r3 
   Not available 

Do the other machines have .Net 2.0 installed? The FileNotFoundException sounds like it cannot find the CLR.

This link describes another issue (with resolution) similar to your problem.


Maybe this is not very relevant, but I face the same issue with the error message being totally unspecific. Here is the error that I received

- <Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
- <System>
  <Provider Name=".NET Runtime" /> 
  <EventID Qualifiers="0">1026</EventID> 
  <Level>2</Level> 
  <Task>0</Task> 
  <Keywords>0x80000000000000</Keywords> 
  <TimeCreated SystemTime="2014-03-16T08:38:12.000000000Z" /> 
  <EventRecordID>8249</EventRecordID> 
  <Channel>Application</Channel> 
  <Computer>ADCOWDPTEST1</Computer> 
  <Security /> 
  </System>
- <EventData>
  <Data>Application: Well Abandonment Automation.exe Framework Version: v4.0.30319 Description: The process was terminated due to an unhandled exception. Exception Info: System.IO.FileNotFoundException Stack: at WA.Client.RequestList.InitializeComponent() at WA.Client.RequestList..ctor() at WA.Client.Program.Main()</Data> 
  </EventData>
  </Event> 

After a little digging around, I discovered I was referencing third party Dlls that was installed on my development machine and not installed on the server.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜