I have a class:
public GenericImplementation:IGeneric<ICar>
{
public IDrive DriveImplementation {get;set;}
}
And an interface:
public interface IGeneric<ICar>
{
}
public interface IDrive<T>
{
void Drive(T);
}
And an implementation:
public class Drive:IDrive<ICar>
{
public void Drive(ICar car)
{
}
}
And a class that uses IGeneric:
public class GenericUser:IUser
{
public IGeneric GenericImplementation {get;set;}
}
All classes exist under carnamespace.
In spring.net configuration, I have:
<object id="Drive" type="carnamespace.Drive, carnamespace"/>
<object id="GenericImplementation" type="carnamespace.GenericImplementation, carnamespace">
<property name="DriveImplementation" ref="Drive"/>
</object>
<object id="GenUser" type="carnamespace.GenericUser, carnamespace">
<property name="GenericImplementation" value="GenericImplementation"/>
</object>
But I keep getting this error:
PropertyAccessExceptionsException (1 errors); nested PropertyAccessExceptions are:
[Spring.Core.TypeMismatchException: Cannot convert property value of type [carnamespace.GenericImplementation] to required type [carnamespace.IGeneric`1[[carnamespace.ICar, carnamespace, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]] for property 'GenericImplementation'., Inner Exception: Spring.Core.TypeMismatchException:
Can someone please help me understand what the resolution is?
There is one obvious flaw in your configuration:
This gave me a
PropertyAccessExceptions
with a nestedTypeMismatchException
too.I've had a hard time reproducing your problem, because your code doesn't compile. If this doesn't solve your problem, please post a compiling code sample. Also, make sure you can at least construct your objects in code, e.g.: