2

我使用OpenNetCF's IoC framework,在我的計劃類的代碼如下所示:OpenNetCF.IoC不能打開始SmartClientApplication

public class Program : SmartClientApplication<Container> 
    { 
     /// <summary> 
     /// The main entry point for the application. 
     /// </summary> 
     [MTAThread] 
     static void Main() 
     { 
      if (!string.Equals(RegionInfo.CurrentRegion.EnglishName, "New Zealand") || 
       !string.Equals(TimeZone.CurrentTimeZone.StandardName, "New Zealand Standard Time")) 
      { 
       MessageBox.Show("Please set your regional and time zone settings to New Zealand."); 
       return; 
      } 

      AppDomain.CurrentDomain.UnhandledException += CurrentDomainUnhandledException; 

      new Program().Start(); 
     } 

     static void CurrentDomainUnhandledException(object sender, UnhandledExceptionEventArgs e) 
     { 
      if (Debugger.IsAttached) 
      { 
       Debugger.Break(); 
      } 
     } 
    } 

我已經複製到OpenNETCF我的解決方案,我期待當計劃() 。開始()被調用,所以我設置就可以了破發點,將跳轉到start方法在這裏:

public abstract class SmartClientApplication<TShell> 
    where TShell : Form 
{ 
    /// <summary> 
    /// This method loads the Profile Catalog Modules by calling GetModuleInfoStore which, unless overridden, uses a DefaultModuleInfoStore instance. 
    /// It then creates an instance of TShell and calls Application.Run with that instance. 
    /// </summary> 
    public void Start() 
    { 
     // load up the profile catalog here 
     IModuleInfoStore store = GetModuleInfoStore(); 

     Start(store); 
    } 

奇怪的是它永遠不會命中斷點。

我認爲這很奇怪,所以我在程序中單擊導航到從繼承引用到SmartClientApplication的定義。

這開了一個完全不同的文件到一個我期待,看起來像:

using OpenNETCF.IoC; 
using System; 
using System.Windows.Forms; 

namespace OpenNETCF.IoC.UI 
{ 
    public abstract class SmartClientApplication<TShell> where TShell : System.Windows.Forms.Form 
    { 
     protected SmartClientApplication(); 

     public virtual void AddServices(); 
     protected virtual void AfterShellCreated(); 
     public virtual IModuleInfoStore GetModuleInfoStore(); 
     public virtual void OnApplicationRun(Form form); 
     public virtual void OnModuleLoadComplete(string moduleName); 
     public void Start(); 
     public void Start(string profileCatalog); 
    } 
} 

名稱相同,但內容似乎並沒有包含任何實現。當我看到它的位置是這樣的:

C:\ Users \ myusername \ AppData \ Local \ Temp \ 7212 $ OpenNETCF.IoC.UI.dll $ v2.0.50727 \ OpenNETCF.IoC.UI.SmartClientApplication。 cs

這樣就解釋了爲什麼它沒有達到斷點,但我想知道的是爲什麼它甚至看着這個瘋狂的文件,而不是它應該是的。

回答

2

聽起來好像您在開發機器上有多個源代碼和PDB副本。如果您構建了一個IoC示例,然後將批發文件夾(包括obj和bin文件夾)複製到您的應用程序的路徑中,這可能會發生。

的溶液(或至少開始是)是做到以下幾點:

  • 從您的項目中刪除的IoC引用(S)
  • 構建產生錯誤
  • 打開資源管理器從您的解決方案樹刪除所有OBJ和bin文件夾
  • 重新添加引用(一個或多個)
  • 重建