2010-11-24 23 views
5

每次我這個自定義欄目做了ConfigurationManager.GetSection("registeredPlugIns")我收到此錯誤:自定義的ConfigurationSection類型不正確加載

出錯創建registeredPlugIns配置節處理程序:

Could not load type 'Engine.PlugInArch.PlugInConfigurationSection' from assembly 'System.Configuration, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.

爲什麼嘗試從System.Configuration加載類型而不是我要求的程序集?

這是我第代碼:

namespace Engine.PlugInArch 
{ 
    public class PlugInConfigurationSection : ConfigurationSection 
    { 
     [ConfigurationProperty("plugIns", IsDefaultCollection = false), 
     ConfigurationCollection(typeof(PlugInCollection), AddItemName = "addPlugin")] 
     public PlugInCollection PlugIns 
     { 
      get { return this["plugIns"] as PlugInCollection; } 
     } 

    } 
} 

,這裏是我的app.config

<configuration> 
    <configSections> 
    <section name="registeredPlugIns" type="Engine.PlugInArch.PlugInConfigurationSection, Engine"/> 
    </configSections> 
     ... 
    <registeredPlugIns> 
     <plugIns> 
      <addPlugIn DllName="ProcessorPlugin.dll"/> 
     </plugIns> 
    </registeredPlugIns> 

</configuration> 

回答

10

正所謂Engine.dll您的DLL?我認爲不是,那是問題所在。

好的,從sysinternals運行procmon。將篩選器設置爲進程名稱,並篩選result =「NAME NOT FOUND」。您將看到正在查找Engine.dll或Engine.exe的條目。看看它在哪裏尋找它,這可能是文件需要被複制到正在運行的文件夾。

+0

它實際上是Engine.exe會這麼重要嗎?它們的類型位於引用此app.config的程序集中。 – 2010-11-24 16:36:01

相關問題