Your first reference is actually a book on the Java version of Spring. Spring.net is a port to .net of the Spring for Java framework, with many similarities, but also some differences. The documentation on spring.net is at www.springframework.net/.
According to the docs on autowiring:
[Spring.net] will look for an object named exactly the same as the property which needs to be autowired. For example, if you have an object definition that is set to autowire by name, and it contains a Master property, Spring.NET will look for an object definition named Master, and use it as the value of the Master property on your object definition.
So I guess you have to change your object definition to
<object id = "Desc" type = "ConsoleApplication6.Description">
<property name = "_d" value = "I am the description"/>
</object>
And you might have to make Texte.Desc
public
instead of internal
, but I'm not really sure about that one.
Update
Well, this works for me:
using System;
using NUnit.Framework;
using Spring.Context.Support;
namespace XmlConfig.AutoWireByName
{
[TestFixture]
public class AutoWireByName
{
[Test]
public void LetsAutoWireByName()
{
var ctx = new XmlApplicationContext("AutoWireByName/objects.xml");
var texte = (Texte)ctx.GetObject("texte");
texte.Print();
}
}
class Texte
{
public string T { get; set; }
public Description Desc { get; set; }
public void Print()
{
Console.WriteLine("text in object: " + T);
Console.WriteLine("text description: " + Desc.D);
}
}
class Description
{
public string D { get; set; }
}
}
<?xml version="1.0" encoding="utf-8" ?>
<objects xmlns="http://www.springframework.net">
<object id = "texte" type = "XmlConfig.AutoWireByName.Texte, XmlConfig" autowire="byName">
<property name = "T" value = "I am the Text"/>
</object>
<object id = "Desc" type = "XmlConfig.AutoWireByName.Description, XmlConfig">
<property name = "D" value = "I am the description"/>
</object>
</objects>