2012-01-01 13 views
0

私は問題を解決するのに苦労しており、本当に助けに感謝します。Spring.Core.TypeMismatchException:型のプロパティ値を変換できません

public interface ISolver<T> 
{ 
     void Solve(); 
} 

public class Solver : ISolve<IEntity> 
{ 
    void Solve() 
{ 
...code that solves the given problem 
} 
} 

public class Client : IClient<IEntity> 
{ 

     public Dictionary<string, ISolver<IEntity>> Solvers { get; set; } 
} 

すべてがネームスペースソリューションの一部です。 Spring.Net構成で

<object id="Client" type="solution.Client, solution"> 
<property name="Solvers"> 
     <dictionary key-type="string" value-type="solution.Solver, solution"> 
     <entry key="SolverMp" value-ref="SolverMp"></entry> 
     </dictionary> 
    </property> 
</object> 

<object id="SolverMp" type="solution.Solver, solution"> 
</object> 

私は例外を取得:

Spring.Core.TypeMismatchException:型のプロパティ値を変換できません[System.Collections.Generic.Dictionary` 2 [[System.String、mscorlib、Version = 4.0.0.0、Culture =ニュートラル、PublicKeyToken = b77a5c561934e089]、[solution.Solver、solution、Version = 1.0.0.0、Culture = neutral、PublicKeyToken = null]]] [System.Collections.Generic.Dictionary`2 [[System.String、mscorlib、Version = 4.0.0.0、Culture = neutr PublicKeyToken = PublicKeyToken = b77a5c561934e089]、[solution.ISolver`1 [[solution.IEntity、solution、バージョン= 1.0.0.0、Culture =ニュートラル、PublicKeyToken = null]]、ソリューション、バージョン= 1.0.0.0、Culture =ニュートラル、PublicKeyToken = null]]]プロパティ 'Solvers'に対して。

+0

私はあなたが 'ソルバーを意味すると仮定します。ISolver '先頭に、それはタイプミス – annonymously

答えて

3
<objects xmlns="http://www.springframework.net"> 
    <object id="Client" type="solution.Client, solution"> 
    <property name="Solvers"> 
     <dictionary key-type="string" value-type="solution.ISolver&lt;solution.IEntity&gt;, solution"> 
     <entry key="SolverMp" value-ref="SolverMp"></entry> 
     </dictionary> 
    </property> 
    </object> 
</objects> 
1

少なくとも一つの問題は、あなたの設定でこのエントリです:

value-type="solution.Solver 

ソルバーの辞書の値型は

ISolver<IEntity>> 

であり、これは例外が文句を言っているものです。

+0

だそして、あなたはこれを達成するためにダーリンの設定を使用することができます。 – Marijn

関連する問題