Structure map and generics (in XML config)
- by James D
Hi
I'm using the latest StructureMap (2.5.4.264), and I need to define some instances in the xml configuration for StructureMap using generics. However I get the following 103 error:
Unhandled Exception: StructureMap.Exceptions.StructureMapConfigurationException: StructureMap configuration failures:
Error: 103
Source:
Requested PluginType MyTest.ITest`1[[MyTest.Test,MyTest]] configured in Xml cannot be found
Could not create a Type for 'MyTest.ITest`1[[MyTest.Test,MyTest]]'
System.ApplicationException: Could not create a Type for 'MyTest.ITest`1[[MyTest.Test,MyTest]]' ---> System.TypeLoadException: Could not loa
d type 'MyTest.ITest`1' from assembly 'StructureMap, Version=2.5.4.264, Culture=neutral, PublicKeyToken=e60ad81abae3c223'.
at System.RuntimeTypeHandle._GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark&
stackMark, Boolean loadTypeFromPartialName)
at System.RuntimeTypeHandle.GetTypeByName(String name, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark&
stackMark)
at System.RuntimeType.PrivateGetType(String typeName, Boolean throwOnError, Boolean ignoreCase, Boolean reflectionOnly, StackCrawlMark& s
tackMark)
at System.Type.GetType(String typeName, Boolean throwOnError)
at StructureMap.Graph.TypePath.FindType()
--- End of inner exception stack trace ---
at StructureMap.Graph.TypePath.FindType()
at StructureMap.Configuration.GraphBuilder.ConfigureFamily(TypePath pluginTypePath, Action`1 action)
A simply replication of the code is as follows:
public interface ITest<T>
{
}
public class Test
{
}
public class Concrete : ITest<Test>
{
}
Which I then wish to define in the XML configuration something as follows:
<DefaultInstance
PluginType="MyTest.ITest`1[[MyTest.Test,MyTest]],MyTest"
PluggedType="MyTest.Concrete,MyTest"
Scope="Singleton"
/>
I've been racking my brain, however I can't see what I'm doing wrong - I've used Type.GetType to verify the type actually is valid which it is. Anyone have any ideas?
Thanks !