Quantcast
Channel: Managed Extensibility Framework
Viewing all articles
Browse latest Browse all 265

Created Unassigned: AmbiguousMatchException when resolving a class with generic void overloads [14614]

$
0
0
Hi,

To reproduce this problem, consider the following class:

``` C#
public class Test
{
public void Execute() { }

public void Execute<T>() { }
}
```

The following code will fail with an AmbiguousMatchException:

``` C#
var conventions = new ConventionBuilder();

conventions.ForType<Test>().Export();

var container = new ContainerConfiguration()
.WithAssembly(typeof(Test).Assembly, conventions)
.CreateContainer();
```

The stack trace is:

```
System.Reflection.AmbiguousMatchException: Ambiguous match found.
at System.DefaultBinder.SelectMethod(BindingFlags bindingAttr, MethodBase[] match, Type[] types, ParameterModifier[] modifiers)
at System.RuntimeType.GetMethodImpl(String name, BindingFlags bindingAttr, Binder binder, CallingConventions callConv, Type[] types, ParameterModifier[] modifiers)
at System.Type.GetMethod(String name, Type[] types)
at System.Reflection.RuntimeReflectionExtensions.GetRuntimeMethod(Type type, String name, Type[] parameters)
at System.Composition.Convention.PartConventionBuilder.BuildOnImportsSatisfiedNotification(Type type, List`1& configuredMembers)
at System.Composition.Convention.ConventionBuilder.EvaluateThisTypeInfoAgainstTheConvention(TypeInfo typeInfo)
at System.Composition.Convention.ConventionBuilder.GetCustomAttributes(Type reflectedType, MemberInfo member)
at System.Composition.Convention.AttributedModelProviderExtensions.GetDeclaredAttribute[TAttribute](AttributedModelProvider convention, Type reflectedType, MemberInfo member)
at System.Composition.TypedParts.Discovery.TypeInspector.InspectTypeForPart(TypeInfo type, DiscoveredPart& part)
at System.Composition.TypedParts.TypedPartExportDescriptorProvider..ctor(IEnumerable`1 types, AttributedModelProvider attributeContext)
at System.Composition.Hosting.ContainerConfiguration.CreateContainer()
...
```

This affects the current release of MEF 2 (Microsoft.Composition 1.0.27).

Viewing all articles
Browse latest Browse all 265

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>