Structure map and generics (in XML config)

Posted by James D on Stack Overflow See other posts from Stack Overflow or by James D
Published on 2009-10-08T11:25:35Z Indexed on 2010/03/26 17:03 UTC
Read the original article Hit count: 228

Filed under:
|
|
|
|

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 !

© Stack Overflow or respective owner

Related posts about structuremap

Related posts about Xml