2

Closed

Umapper throws error in Umbraco 4.11.6 and umbraco 6+

description

In Umbraco 4.11.6 and umbraco 6+

uMapper.CreateMap<HomePage>()

falis with Reflection.AmbiguousMatchException

StackTrace:

uComponents.Mapping.Property.PropertyMapperBase..ctor(NodeMapper nodeMapper, PropertyInfo destinationProperty)
in uComponents.Mapping.Property.BasicPropertyMapper..ctor(Func`2 mapping, Type sourcePropertyType, NodeMapper nodeMapper, PropertyInfo destinationProperty, String sourcePropertyAlias)
in uComponents.Mapping.NodeMapper..ctor(NodeMappingEngine engine, Type destinationType, DocumentType sourceDocumentType)
in uComponents.Mapping.NodeMappingEngine.CreateMap[TDestination](String documentTypeAlias)
in uComponents.Mapping.NodeMappingEngine.CreateMapTDestination
in uComponents.Mapping.uMapper.CreateMapTDestination
in ProjectName.MyStartupHandler.OnApplicationStarted(UmbracoApplication httpApplication, ApplicationContext applicationContext) in c:\Work\ProjectName\MyStartupHandler.cs
Closed May 31, 2013 at 10:50 PM by diachedelic
This is fixed on the 5.4.2-dev branch, will be merged into the 6.0.0 branch at some point i'm sure

comments

syska wrote May 12, 2013 at 11:22 PM

Same issue here ...

mvh

syska wrote May 13, 2013 at 12:23 AM

private readonly static MethodInfo _getNodePropertyMethod = typeof(NodeExtensions).GetMethod("GetProperty");

Its trying to figure out to use: INode or Node. The "AmbiguousMatchException" part.

Not that strong in reflection stuff ... so really no idea yet how to fix it.

syska wrote May 13, 2013 at 12:42 AM

Changing line 17 in PropertyMapperBase.cs
from
private readonly static MethodInfo _getNodePropertyMethod = typeof(NodeExtensions).GetMethod("GetProperty");
to
private readonly static MethodInfo _getNodePropertyMethod = typeof(NodeExtensions).GetMethod("GetProperty", new Type[] { typeof(Node), typeof(string) });

This should fix the problem. I will try and make a pull request tomorrow.

diachedelic wrote May 13, 2013 at 8:52 AM

Hey syska, I'll fix this today or tomorrow, don't worry about doing a pull request.

Thanks for the bug and solution!

James

syska wrote May 13, 2013 at 9:10 AM

Well ... to get started helping the open source(which I have used for many years now), this seems to be a simple job to start helping.

This solution seems to work for me.

Please, add any comments on the issue. Want to give something back to the Open Source now.

matt_lethargic wrote May 30, 2013 at 2:14 PM

This didn't work for me in 4.11.8, still getting same error

matt_lethargic wrote May 30, 2013 at 2:54 PM

Ignore my comments above :-)

pedroadao wrote Jun 6, 2013 at 5:47 PM

Still have the same error. :(

I have umbraco v6.1, upgraded uComponents from v4.6 to v6 -dev using nuGet

uComponents.Code 6.0.0.0
uComponents.Mappign 1.0.0.0

diachedelic wrote Jun 6, 2013 at 8:26 PM

Ah...the change was not merged into the 6.0.0 branch.

I have grafted those changes into 6.0.0 from 5.4.2 - try it now, it should be fine.