0
我在使用spring.net創建對象時遇到問題,並且需要解決方案。如何使用spring.net爲TypeAliases做屬性注入
安裝說明: 我有下面的TypeAliases配置文件。
<objects xmlns="http://www.springframework.net" >
<object id="TypeAlias" type="Spring.Objects.Factory.Config.TypeAliasConfigurer, Spring.Core">
<property name="TypeAliases">
<dictionary>
<entry key="ABCHost" value-ref="XYZ"/>
</dictionary>
</property>
</object>
<object id="XYZ" type="ABC.ABCHost, ABCHost" >
<property name="Viewer" ref="ViewerFactory" />
</object>
</objects>
爲什麼我做物業注入是因爲ObjectPoolFactory使用默認的構造函數。創建對象時,我希望通過下面的spring文件創建這個Viewer屬性。
<object id="ViewerFactory" type="XYZViewerFactory, XYZViewer" singleton ="true">
</object>
問題: 當運行應用程序,我接到一個電話到默認ABCHost類和觀衆財產的構造函數獲取值XYZViewer。之後,我得到一個彈簧錯誤 -
ServiceProvider.get_AppContext - ServiceProvider.cs(31)
Spring Error :
Spring.Objects.Factory.ObjectInitializationException:
------------------------------------
--- Message
------------------------------------
Invalid value 'ABCHost' for custom type alias - must be a System.String or System.Type.
------------------------------------
--- Stack Trace
------------------------------------
at Spring.Objects.Factory.Config.AbstractConfigurer.ResolveRequiredType(Object value, String errorContextSource, String errorContext)
你能幫助找到解決這個問題的辦法嗎?提前致謝。