question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

AmbiguousMatchException: Multiple custom attributes of the same type found.

See original GitHub issue

I’m using XmlSerializer app.UseSoapEndpoint<IcTransactionService>("/services/IcTransactionService", new BasicHttpBinding(), SoapSerializer.XmlSerializer, true);

and my request object contains multiple xmlelement’s attributes like

[System.Xml.Serialization.XmlElementAttribute("Element1", typeof(ClassType1), Order=4)] [System.Xml.Serialization.XmlElementAttribute("Element2", typeof(ClassType2), Order=4)]

I got this exceptions once I pulled wsdl

An unhandled exception occurred while processing the request. AmbiguousMatchException: Multiple custom attributes of the same type found. System.Attribute.GetCustomAttribute(MemberInfo element, Type attributeType, bool inherit)

Stack Query Cookies Headers Routing AmbiguousMatchException: Multiple custom attributes of the same type found. System.Attribute.GetCustomAttribute(MemberInfo element, Type attributeType, bool inherit) System.Reflection.CustomAttributeExtensions.GetCustomAttribute<T>(MemberInfo element) SoapCore.Meta.MetaBodyWriter.AddSchemaTypeProperty(XmlDictionaryWriter writer, PropertyInfo property, TypeToBuild parentTypeToBuild) SoapCore.Meta.MetaBodyWriter.AddSchemaComplexType(XmlDictionaryWriter writer, TypeToBuild toBuild) SoapCore.Meta.MetaBodyWriter.AddTypes(XmlDictionaryWriter writer) SoapCore.Meta.MetaBodyWriter.OnWriteBodyContents(XmlDictionaryWriter writer) System.ServiceModel.Channels.BodyWriter.WriteBodyContents(XmlDictionaryWriter writer) System.ServiceModel.Channels.BodyWriterMessage.OnWriteBodyContents(XmlDictionaryWriter writer) System.ServiceModel.Channels.Message.WriteBodyContents(XmlDictionaryWriter writer) SoapCore.Meta.MetaMessage.OnWriteBodyContents(XmlDictionaryWriter writer) System.ServiceModel.Channels.Message.OnWriteMessage(XmlDictionaryWriter writer) System.ServiceModel.Channels.Message.WriteMessage(XmlDictionaryWriter writer) System.ServiceModel.Channels.Message.WriteMessage(XmlWriter writer) SoapCore.MessageEncoder.SoapMessageEncoder.WriteXmlCore(Message message, XmlWriter xmlWriter) SoapCore.MessageEncoder.SoapMessageEncoder.WriteMessageAsync(Message message, PipeWriter pipeWriter) SoapCore.SoapEndpointMiddleware<T_MESSAGE>.ProcessMeta(HttpContext httpContext) SoapCore.SoapEndpointMiddleware<T_MESSAGE>.ProcessOperation(HttpContext httpContext, IServiceProvider serviceProvider) SoapCore.SoapEndpointMiddleware<T_MESSAGE>.Invoke(HttpContext httpContext, IServiceProvider serviceProvider) Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context)

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:14 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
timametcommented, Oct 12, 2020

You are right, I found another properties which contains multiple XmlElement attributes. And I can confirm the described case doesn’t throw an exception anymore.

Let me cover all properties with XmlChoice approach and I let you know. Thanks

0reactions
github-actions[bot]commented, Aug 18, 2021

This issue was closed because it has been inactive for 14 days since being marked as stale.

Read more comments on GitHub >

github_iconTop Results From Across the Web

ASP.NET Core 2.1 code generation error - Multiple custom ...
I have a DbContext that contains several DbSets of classes, with some of the classes have properties of class types that are not...
Read more >
multiple custom attributes of the same type
AmbiguousMatchException : Multiple custom attributes of the same type found. at System.Attribute.GetCustomAttribute(MemberInfo element, Type ...
Read more >
Intermittent: Multiple custom attributes of the same type found.
I have a class in VB which inherits from a C# base class. The derived VB class has an attribute applied to it...
Read more >
Multiple custom attributes of the same type found error.
We are having a strange issue, probably related to bug CSHARP-1807. Using full .NET Framework we are now using System.Runtime.
Read more >
Attribute.GetCustomAttribute Method (System)
Retrieves a custom attribute of a specified type applied to an assembly, module, type member, ... More than one of the requested attributes...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found