I wanted to get started with AOP, so simplified Spring.AopQuickStart.Step1 sample to fit into simple VS.NET 2005 project.
I get following error "Unable to cast object of type 'CompositionAopProxy_6839ee888b5144eb86aa6df347e48 e21' to type 'ICommand'" while creating proxy.
Following is the code and web.config.Any help is appreciated. Thanks
class Program
{
static void Main(string[] args)
{
IApplicationContext ctx = ContextRegistry.GetContext();
//Get error here on line below
ICommand command = (ICommand)(ctx["myServiceCommand"]);
command.Execute();
}
}
interface ICommand
{
bool IsUndoCapable { get; }
void Execute();
void UnExecute();
}
class ServiceCommand : ICommand
{
bool ICommand.IsUndoCapable
{get { return true; }}
void ICommand.Execute() {}
void ICommand.UnExecute() {}
}
config file below:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<sectionGroup name="spring">
<section name="context" type="Spring.Context.Support.ContextHandler, Spring.Core" />
<section name="objects" type="Spring.Context.Support.DefaultSectionHandler , Spring.Core" />
</sectionGroup>
</configSections>
<spring>
<context>
<resource uri="config://spring/objects" />
</context>
<objects xmlns="http://www.springframework.net">
<description>An example that demonstrates simple AOP functionality.</description>
<object id="myServiceCommand" type="Spring.Aop.Framework.ProxyFactoryObject, Spring.Aop">
<property name="Target">
<object type="ServiceCommand, SprintNetAOP" />
</property>
</object>
</objects>
</spring>
</configuration>
Thanks


Reply With Quote