Hi there,
The issue IOC-ISSUE-146 was just created by Poul (pbn).
Key: IOC-ISSUE-146
Summary: Problem with circular references
Type: Bug
Importance: High
Description:
Hello,
I am having problems with circular references between classes. Consider the
following example code.
public interface IMaster
{
}
public interface ISlave
{
}
public class Master : IMaster
{
private ISlave slave;
public ISlave Slave
{
get { return this.slave; }
set { this.slave = value; }
}
}
public class Slave : ISlave
{
private IMaster master;
public IMaster Master
{
get { return this.master; }
set { this.master = value; }
}
}
Try and resolve the master
IWindsorContainer container = ...
IMaster master = container.Resolve<IMaster>();
Problem 1:
Use Castle auto-wire (No explicit set of Master/Slave properties) with the
following XML:
<component id="Master1" service="CastleSample.IMaster, CastleSample"
type="CastleSample.Master, CastleSample">
<parameters>
</parameters>
</component>
<component id="Slave1" service="CastleSample.ISlave, CastleSample"
type="CastleSample.Slave, CastleSample">
<parameters>
</parameters>
</component>
This returns an IMaster instance with its Slave property set to a slave
instance. However, the slave does not have its Master property set. It is null.
Would expect the Master property on the slave instance to be set to the master.
Problem 2:
Explicit set the Master and Slave properties with the following XML:
<component id="Master1" service="CastleSample.IMaster, CastleSample"
type="CastleSample.Master, CastleSample">
<parameters>
<Slave>${Slave1}</Slave>
</parameters>
</component>
<component id="Slave1" service="CastleSample.ISlave, CastleSample"
type="CastleSample.Slave, CastleSample">
<parameters>
<Master>${Master1}</Master>
</parameters>
</component>
This fails with a HandlerException with the following contents:
Can't create component 'Master1' as it has dependencies to be satisfied.
Master1 is waiting for the following dependencies:
Keys (components with specific keys)
- Slave1 which was registered but is also waiting for dependencies.
Slave1 is waiting for the following dependencies:
Keys (components with specific keys)
- Master1 which was registered but is also waiting for dependencies.
For more, see
http://support.castleproject.org/projects/IOC/issues/view/IOC-ISSUE-146
--
donjon
by Castle Stronghold
http://www.castle-donjon.com
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Castle Project Development List" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/castle-project-devel?hl=en
-~----------~----~----~----~------~----~------~--~---