Hi, I am trying to create an ITargetSourceCreator for kicks and then configure it to be used by DefaultAdvisorAutoProxyCreator via the CustomTargetSourceCreatorProperty (in XML config) like so:

HTML Code:
<?xml version="1.0" encoding="utf-8"?>
<objects xmlns="http://www.springframework.net">
    <object id="ConsoleLoggingBeforeAdvice" type="Spring.Aop.Support.DefaultPointcutAdvisor" singleton="false">
        <property name="Advice">
            <object type="Spring.Examples.AopQuickStart.ConsoleLoggingBeforeAdvice"/>
        </property>
    </object>

    <object id="ServiceCommand" type="Spring.Examples.AopQuickStart.ServiceCommand" singleton="false"/>

    <object id="PrototypeTargetSourceCreator" type="Spring.Examples.AopQuickStart.PrototypeTargetSourceCreator"/>

    <object type="Spring.Aop.Framework.AutoProxy.DefaultAdvisorAutoProxyCreator">
        <property name="CustomTargetSourceCreators">
            <list element-type="string">
                <value>PrototypeTargetSourceCreator</value>
            </list>
        </property>
    </object>
</objects>
The primary reason I am doing this is to address the issue posted in this thread. While someone can hopefully help me on that quesiton, I thought I'll do more experiments. And as part of those experiments, I've run into something that may potentially be an issue with the framework code.

For reference, my implementation of the ITargetSourceCreator is as follows:

Code:
public class PrototypeTargetSourceCreator : AbstractPrototypeTargetSourceCreator {
    protected override AbstractPrototypeTargetSource CreatePrototypeTargetSource(Type objectType, string name, IObjectFactory factory) {
        Console.WriteLine(objectType);
        Console.WriteLine(name);
        Console.WriteLine(factory);

        if (factory.ContainsObject(name) && factory.IsPrototype(name)) {
            return new PrototypeTargetSource();
        }

        return null;
    }
}
Now, when I run the application, I get an exception in Spring.Aop.Framework.AutoProxy.AbstractAutoProxyCr eator at line 425. The actual line of code is:

Code:
ITargetSourceCreator tsc = (ITargetSourceCreator)customTargetSourceCreators[i]
and here's the stack trace:

System.TypeInitializationException: The type initializer for 'Spring.Examples.AopQuickStart.ObjectRegistry' threw an exception. ---> Spring.Objects.Factory.ObjectCreationException: Error creating object with name 'PrototypeTargetSourceCreator' defined in 'file [C:\Users\ejan\Learning\PracticeBench\Spring.NET\Sp ring.Examples.AopQuickStart\bin\Debug\Objects.xml] line 11' Initialization of object failed : Unable to cast object of type 'System.String' to type 'Spring.Aop.Framework.AutoProxy.ITargetSourceCreat or'. ---> System.InvalidCastException: Unable to cast object of type 'System.String' to type 'Spring.Aop.Framework.AutoProxy.ITargetSourceCreat or'.
at Spring.Aop.Framework.AutoProxy.AbstractAutoProxyCr eator.GetCustomTargetSource(Type*objectType,*Strin g*name) in AbstractAutoProxyCreator.cs: line 425
at Spring.Aop.Framework.AutoProxy.AbstractAutoProxyCr eator.PostProcessBeforeInstantiation(Type*objectTy pe,*String*objectName) in AbstractAutoProxyCreator.cs: line 655
at Spring.Objects.Factory.Support.AbstractAutowireCap ableObjectFactory.ApplyObjectPostProcessorsBeforeI nstantiation(Type*objectType,*String*objectName) in AbstractAutowireCapableObjectFactory.cs: line 330
at Spring.Objects.Factory.Support.AbstractAutowireCap ableObjectFactory.InstantiateObject(String*name,*R ootObjectDefinition*definition,*Object[]*arguments,*Boolean*allowEagerCaching,*Boolean*sup pressConfigure) in AbstractAutowireCapableObjectFactory.cs: line 896
--- End of inner exception stack trace ---
at Spring.Objects.Factory.Support.AbstractAutowireCap ableObjectFactory.InstantiateObject(String*name,*R ootObjectDefinition*definition,*Object[]*arguments,*Boolean*allowEagerCaching,*Boolean*sup pressConfigure) in AbstractAutowireCapableObjectFactory.cs: line 938
at Spring.Objects.Factory.Support.AbstractObjectFacto ry.CreateAndCacheSingletonInstance(String*objectNa me,*RootObjectDefinition*objectDefinition,*Object[]*arguments) in AbstractObjectFactory.cs: line 2144
at Spring.Objects.Factory.Support.AbstractObjectFacto ry.GetObjectInternal(String*name,*Type*requiredTyp e,*Object[]*arguments,*Boolean*suppressConfigure) in AbstractObjectFactory.cs: line 2065
at Spring.Objects.Factory.Support.AbstractObjectFacto ry.GetObject(String*name) in AbstractObjectFactory.cs: line 1826
at Spring.Objects.Factory.Support.DefaultListableObje ctFactory.PreInstantiateSingletons() in DefaultListableObjectFactory.cs: line 505
at Spring.Context.Support.AbstractApplicationContext. Refresh() in AbstractApplicationContext.cs: line 1017
at Spring.Context.Support.XmlApplicationContext..ctor (XmlApplicationContextArgs*args) in XmlApplicationContext.cs: line 111
at Spring.Context.Support.XmlApplicationContext..ctor (String[]*configurationLocations) in XmlApplicationContext.cs: line 128
at Spring.Examples.AopQuickStart.ObjectRegistry..ccto r() in ObjectRegistry.cs: line 6
--- End of inner exception stack trace ---
at Spring.Examples.AopQuickStart.ObjectRegistry.Resol ve<T>(String*name)
at Spring.Examples.AopQuickStart.Program.Main() in C:\Users\ejan\Learning\PracticeBench\Spring.NET\Sp ring.Examples.AopQuickStart\Program.cs: line 8
So it looks like it's directly converting the string "PrototypeTargetSourceCreator" (from XML config) to ITargetSourceCreator. I think it should use the IObjectFactory to resolve this name to an ITargetSourceCreator instance.

Besides, I couldn't find any concrete implementations of ITargetSourceCreator which suggests this may be a work in progress. But most certainly, I think the fact that we don't have any concrete ITargetSourceCreator implementations is the reason for the issue I mentioned above.

Any thoughts?