2011-04-07 7 views
0

예기치 않게 응용 프로그램이 멈 춥니 다. 오류를 해결하기 위해 모든 노력을했지만 솔루션을 찾을 수 없습니다. 이것은 Windows 응용 프로그램입니다.응용 프로그램이 예기치 않게 중지되었습니다.

UPDATE :

이벤트 뷰어 :

1

Faulting application viamura.crawlerapp.exe, version 1.0.0.0, stamp 4d9d9be8, faulting module imon.dll, version 2.70.16.0, stamp 455c9b06, debug? 0, fault address 0x0002474a. 

2

Application: ViaMura.CrawlerApp.exe 
Framework Version: v4.0.30319 
Description: The process was terminated due to an unhandled exception. 
Exception Info: System.AccessViolationException 
Stack: 
    at System.Net.UnsafeNclNativeMethods+OSSOCK.recv(IntPtr, Byte*, Int32, System.Net.Sockets.SocketFlags) 
    at System.Net.Sockets.Socket.Receive(Byte[], Int32, Int32, System.Net.Sockets.SocketFlags, System.Net.Sockets.SocketError ByRef) 
    at System.Net.Sockets.Socket.Receive(Byte[], Int32, Int32, System.Net.Sockets.SocketFlags) 
    at System.Net.Sockets.NetworkStream.Read(Byte[], Int32, Int32) 
    at System.Net.PooledStream.Read(Byte[], Int32, Int32) 
    at System.Net.ConnectStream.ReadSingleByte() 
    at System.Net.StreamChunkBytes.get_NextByte() 
    at System.Net.ChunkParse.GetChunkSize(System.Net.IReadChunkBytes, Int32 ByRef) 
    at System.Net.ConnectStream.ProcessReadChunkedSize(System.Net.StreamChunkBytes) 
    at System.Net.ConnectStream.ReadChunkedCallbackWorker(System.Net.NestedSingleAsyncResult, System.Net.ConnectStream) 
    at System.Net.ConnectStream.ReadChunkedCallback(System.Object) 
    at System.Threading.QueueUserWorkItemCallback.WaitCallback_Context(System.Object) 
    at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean) 
    at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem() 
    at System.Threading.ThreadPoolWorkQueue.Dispatch() 
    at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback() 


For more information, see Help and Support Center at 

3

EventType clr20r3, P1 viamura.crawlerapp.exe, P2 1.0.0.0, P3 4d9d9759, P4 viamura.crawlerapp, P5 1.0.0.0, P6 4d9d9759, P7 e, P8 36, P9 system.exception, P10 NIL. 
,

코드 1 :

try 
      { 
       Application.EnableVisualStyles(); 
       Application.SetCompatibleTextRenderingDefault(false); 
       Application.Run(new CrawlerApp()); 
      } 
      catch (Exception e) 
      { 
       LogError.WriteError("Napaka: " + e.Message); 
       LogError.WriteError("StackTrace: " + e.StackTrace); 
      } 

코드 2 : 예외 .NET 예외 유형이 아닌 경우에

catch (Exception e)    
{ 
    LogError.WriteError("Napaka: " + e.Message); 
    LogError.WriteError("StackTrace: " + e.StackTrace); 
} 
catch 
{ 
    LogError.WriteError("Untyped Exception"); 
} 

:

#region 

using System; 
using System.Collections.Generic; 
using System.ComponentModel; 
using System.Configuration; 
using System.Diagnostics; 
using System.Linq; 
using System.Net; 
using System.Runtime.InteropServices; 
using System.Windows.Forms; 
using WebCrawler.Core.DataInterfaces; 
using WebCrawler.Core.Entities; 
using WebCrawler.Data; 
using WebCrawler.Lib; 
using WebCrawler.Logic; 

#endregion 

namespace ViaMura.CrawlerApp 
{ 
    public delegate void WebSiteVisitedCallback(WebSiteVisitedEventArgs args); 

    public partial class CrawlerApp : Form 
    { 
     #region Properties 

     private IDaoFactory _daoFactory; 
     private IList<Agencies> agencies; 
     private Agencies agency; 
     private CrawlerManager manager; 

     private IDaoFactory DaoFactory 
     { 
      get 
      { 
       if (_daoFactory == null) 
       { 
        _daoFactory = new NHibernateDaoFactory(ConfigurationManager.AppSettings["NHibernateConfigPath"]); 
        return _daoFactory; 
       } 
       else 
        return _daoFactory; 
      } 
     } 

     private string ConnectionString 
     { 
      get { return ConfigurationManager.ConnectionStrings["connectionString"].ConnectionString; } 
     } 

     #endregion 

     #region Methods 

     //static uint LOAD_LIBRARY_AS_DATAFILE = 0x00000002; 
     //static uint LOAD_LIBRARY_AS_DATAFILE_EXCLUSIVE = 0x00000040; 
     //static uint LOAD_WITH_ALTERED_SEARCH_PATH = 0x00000008; 

     public CrawlerApp() 
     {   
      InitializeComponent(); 
      //LoadDLL();   
      Init();    
      LoadAgenciesData();    
     } 

     /*[DllImport("kernel32.dll")] 
     private static extern IntPtr LoadLibraryEx(string dllFilePath, IntPtr hFile, uint dwFlags); 

     [DllImport("kernel32.dll")] 
     public static extern bool FreeLibrary(IntPtr dllPointer); 

     private IntPtr LoadWin32Library(string dllFilePath) 
     { 
      try 
      { 
       IntPtr moduleHandle = LoadLibraryEx(dllFilePath, IntPtr.Zero, LOAD_WITH_ALTERED_SEARCH_PATH); 
       if (moduleHandle == IntPtr.Zero) 
       { 
        // I'm gettin last dll error 
        int errorCode = Marshal.GetLastWin32Error(); 
        throw new ApplicationException(
         string.Format("There was an error during dll loading : {0}, error - {1}", dllFilePath, errorCode) 
         ); 
       } 

       return moduleHandle; 
      } 
      catch (Exception exc) 
      { 
       throw new Exception(String.Format("Couldn't load library {0}{1}{2}", dllFilePath, Environment.NewLine, exc.Message), exc); 
      } 
     }*/ 

     private void Init() 
     { 
      manager = new CrawlerManager(DaoFactory, ConnectionString); 
      manager.OnWebSiteVisited += manager_OnWebSiteVisited; 

      timerSetTime.Start(); 
     } 

     /*private void LoadDLL() 
     { 
      string XulRunnerPath = @"D:\PROJEKTI\crawler\WebCrawlerSuite\NCrawler\GeckoEngine\xulRunner"; 
      //string XulRunnerPath = @"D:\Development\Own\ViaMura\WebCrawlerSuite\NCrawler\GeckoEngine\xulRunner"; 

      string[] files = Directory.GetFiles(XulRunnerPath, "*.dll"); 
      foreach (var file in files) 
      { 
       LoadWin32Library(file); 
      } 
     }*/ 

     private void LoadAgenciesData() 
     { 
      agencies = DaoFactory.GetAgenciesDao().GetAll(); 
      agencies = agencies.OrderBy(a => a.LoadCrawlerDate).ToList(); //TODO performance OrderBy 
     } 

     private void timerSetTime_Tick(object sender, EventArgs e) 
     { 
      lblCurrentTime.Text = DateTime.Now.ToString(); 

      foreach (var tmpAgency in agencies) 
      { 
       if (!tmpAgency.Active || bwCrawler.IsBusy) continue; 

       DateTime? crawlerTime; 
       if (tmpAgency.LoadCrawlerDate != null) 
       { 
        crawlerTime = ((DateTime) tmpAgency.LoadCrawlerDate).AddMinutes(tmpAgency.CrawlerDelayInMinutes); 
       } 
       else 
        crawlerTime = null; 

       if (crawlerTime == null || DateTime.Now > crawlerTime) 
       { 
        try 
        { 
         txtStatus.Text = "Start crawler: " + tmpAgency.Name + " " + DateTime.Now + " " + txtStatus.Text + Environment.NewLine + txtStatus.Text; 
        } 
        catch (Exception ex) 
        { 
         txtStatus.Text = "Error: " + ex.Message; 
        } 

        if (tmpAgency.LoadCrawlerDate != null) 
        { 
         tmpAgency.LoadCrawlerDate = ((DateTime) tmpAgency.LoadCrawlerDate).AddDays(1); 
        } 
        else 
         tmpAgency.LoadCrawlerDate = null; 

        agency = tmpAgency; 
        bwCrawler.RunWorkerAsync(); 
       } 
      } 
     } 

     private void manager_OnWebSiteVisited(object source, WebSiteVisitedEventArgs args) 
     { 
      try 
      { 
       txtStatus.Invoke(new WebSiteVisitedCallback(WebSiteVisited), new object[] { args }); 
      } 
      catch (Exception ex) 
      { 
       throw new Exception(ex.Message); 
      } 
     } 

     private void WebSiteVisited(WebSiteVisitedEventArgs args) 
     { 
      txtStatus.Text = args.Status + " " + args.VisitedUrl + Environment.NewLine + txtStatus.Text; 

      if (args.Status) 
      { 
       lblNumberOfMatches.Text = (Convert.ToInt32(lblNumberOfMatches.Text) + 1).ToString(); 
      } 
      else 
      { 
       lblNumberOfFailures.Text = (Convert.ToInt32(lblNumberOfFailures.Text) + 1).ToString(); 
      } 

      if (txtStatus.Text.Split(new[] { Environment.NewLine }, StringSplitOptions.None).Length > 200) 
      { 
       txtStatus.Text = string.Empty; 
      } 
     } 

     private void bwCrawler_DoWork(object sender, DoWorkEventArgs e) 
     { 
      manager.ExtractDataFromAgency(agency); 
     } 

     private void bwCrawler_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e) 
     { 
      txtStatus.Text = Environment.NewLine + "End and Saved last CrawledDate: " + DateTime.Now + 
          Environment.NewLine + txtStatus.Text; 

      try 
      { 
       IAgenciesDao aDao = DaoFactory.GetAgenciesDao(); 

       agency = aDao.GetById(agency.idAgencies, false); 
       agency.LoadCrawlerDate = DateTime.Now; 

       aDao.SaveOrUpdate(agency); 
       aDao.CommitChanges(); 
      } 
      catch (Exception ex) 
      { 
       txtStatus.Text = ex.Message; 
      } 

      LoadAgenciesData(); 
     } 

     #endregion 
    } 
} 
+3

: 그렇다면, Google은이 문제가 될 수 제안? 너 뭐 벌써 해봤 니? 디버거를 사용하고 단계별로 진행하면 어떻게됩니까? http://tinyurl.com/so-hints –

+0

을 읽으십시오. 주요 방법은 –

+0

입니다. 응용 프로그램을 닫기 만하면 오류가 없습니다. 만약에 하나가 있다면 흥분을 잡으려고 노력하십시오 ... 일하지 않아도 즉시 멈추지 않습니다 ... – senzacionale

답변

1
+0

예 nod32를 실행 중입니다. 나는 그것을 볼 것이다. 고마워 – senzacionale

0

추가 매개 변수가 캐치를 추가 할 수 있습니다. 이 문제 비록 는 CLR 1.1 특정 : Throwing Exceptions That Are Not Exceptions

Catch Exception treatment

추가 link에서도 토론을 참조하십시오 : "프로그램이 다른 언어로 작성된 라이브러리를 사용하는 경우, 다음에서 파생되지 않은 예외가있을 수 있습니다 이러한 예외는 매개 변수가없는 catch 문에서 처리 할 수 ​​있습니다. "

+0

여기에 오류가 없습니다 ...이 코드는 오류로 실행되지 않습니다. – senzacionale

관련 문제