我用Spring.Net编写了应用程序。当我尝试调用Spring.Net的GetObject(“...”)时,我有一个例外:
没有定义名为'SystemConfiguration_Workspace_NewWorkspaceAction'的对象:找不到对象的定义[SystemConfiguration_Workspace_NewWorkspaceAction]
但我的XML中有一个名为'SystemConfiguration_Workspace_NewWorkspaceAction'的对象。
<?xml version="1.0" encoding="utf-8" ?>
<spring>
<typeAliases>
<alias name="ContextMenuItemModelAlias" type="ElmoMotionControl.View.Model.ContextMenuItemModel, ElmoMotionControl.View.Model"/>
</typeAliases>
<objects xmlns="http://www.springframework.net" >
<!--<description>An example that demonstrates simple IoC features.</description>-->
<object id="WorkspaceTreeModel" type="ElmoMotionControl.View.Model.ContextMenuModel, ElmoMotionControl.View.Model" >
<property name="ContextMenus" ref="WorkspaceTreeModelDicProp"/>
</object>
<!-- _______________________The dictionary item______________________ -->
<object id ="WorkspaceTreeModelDicProp" type="System.Collections.Generic.Dictionary<string, System.Collections.Generic.Dictionary<string, System.Collections.Generic.List<ContextMenuItemModelAlias>>>">
<constructor-arg>
<dictionary key-type="string" value-type="System.Collections.Generic.Dictionary<string, System.Collections.Generic.List<ContextMenuItemModelAlias>>">
<entry key="SystemConfiguration_Workspace" value-ref="SystemConfiguration_Workspace"/>
</dictionary>
</constructor-arg>
</object>
.
.
.
</objects>
</spring>
可能是什么问题?
答案 0 :(得分:0)
这是我的整个XML:
<?xml version="1.0" encoding="utf-8" ?>
<spring>
<typeAliases>
<alias name="ContextMenuItemModelAlias" type="ElmoMotionControl.View.Model.ContextMenuItemModel, ElmoMotionControl.View.Model"/>
</typeAliases>
<objects xmlns="http://www.springframework.net" >
<object id="WorkspaceTreeModel" type="ElmoMotionControl.View.Model.ContextMenuModel, ElmoMotionControl.View.Model" >
<property name="ContextMenus" ref="WorkspaceTreeModelDicProp"/>
</object>
<!-- _______________________The dictionary item______________________ -->
<object id ="WorkspaceTreeModelDicProp" type="System.Collections.Generic.Dictionary<string, System.Collections.Generic.Dictionary<string, System.Collections.Generic.List<ContextMenuItemModelAlias>>>">
<constructor-arg>
<dictionary key-type="string" value-type="System.Collections.Generic.Dictionary<string, System.Collections.Generic.List<ContextMenuItemModelAlias>>">
<entry key="SystemConfiguration_Workspace" value-ref="SystemConfiguration_Workspace"/>
</dictionary>
</constructor-arg>
</object>
<!--____________Context Menu Items Lists_______________-->
<object id="SystemConfiguration_Workspace" type="System.Collections.Generic.Dictionary<string, System.Collections.Generic.List<ContextMenuItemModelAlias>>">
<constructor-arg>
<dictionary key-type="string" value-type="System.Collections.Generic.List<ContextMenuItemModelAlias>">
<entry key="SystemConfiguration_Workspace_NewWorkspace" value-ref="SystemConfiguration_Workspace_NewWorkspace1"/>
</dictionary>
</constructor-arg>
</object>
<object id="SystemConfiguration_Workspace_NewWorkspace1" type="System.Collections.Generic.List <ContextMenuItemModelAlias>">
<constructor-arg>
<list element-type="ContextMenuItemModelAlias">
<ref object="SystemConfiguration_Workspace_NewWorkspace"/>
</list>
</constructor-arg>
</object>
<!--_____________________Contecxt Menu Items_______________________-->
<object id="SystemConfiguration_Workspace_NewWorkspace" type="ContextMenuItemModelAlias">
<constructor-arg name="name" value="SystemConfiguration_Workspace_NewWorkspace"/>
<constructor-arg name="isEnable" value="true"/>
<constructor-arg name="action" ref="SystemConfiguration_Workspace_NewWorkspaceAction"/>
</object>
<!--_________________________Actions____________________________-->
<object id="SystemConfiguration_Workspace_NewWorkspaceAction" type="ElmoMotionControl.Activity.Action.SystemConfigurationActivitySelectionAction, ElmoMotionControl.Activity.Action"/>
</objects>
</spring>
“SystemConfiguration_Workspace”是xml中的对象。我希望Spring.Net将创建一个实例。 我不认为SystemConfiguration_Workspace有一个配置为SystemConfiguration_Workspace_NewWorkspaceAction的属性或构造函数,但缺少这个属性或构造函数。
答案 1 :(得分:0)
谢谢,我成功解决了我的问题
我不知道问题是什么,但我在每个级别上课。
一个包含List的类,一个包含字符串字典和最后一个类的类,以及一个包含字符串和最后一个类的类。
为这些类创建XML非常简单。