ASP.NET 4+MongoDB生产环境遇System.Reflection.AmbiguousMatchException求助
ASP.NET 4 + MongoDB REST API 在 Windows 2012 R2 环境下抛出
System.Reflection.AmbiguousMatchException 各位好,我基于ASP.NET 4和MongoDB开发了一个REST API,在本地Windows 10环境以及Windows 2008 R2 + .NET 4.7.1的测试环境中都能正常运行,但部署到Windows 2012 R2 + .NET 4.7.1的生产环境时,却出现了报错。
错误信息
System.Reflection.AmbiguousMatchException: Multiple custom attributes of the same type found. at System.Attribute.GetCustomAttribute(Assembly element, Type attributeType, Boolean inherit) at System.Runtime.InteropServices.RuntimeInformation.get_FrameworkDescription() at System.Lazy`1.CreateValue() at System.Lazy`1.LazyInitValue() at MongoDB.Driver.Core.Connections.ClientDocumentHelper.CreateClientDocument(String applicationName) at MongoDB.Driver.Core.Connections.BinaryConnectionFactory..ctor(ConnectionSettings settings, IStreamFactory streamFactory, IEventSubscriber eventSubscriber) at MongoDB.Driver.Core.Configuration.ClusterBuilder.BuildCluster() at MongoDB.Driver.ClusterRegistry.CreateCluster(ClusterKey clusterKey) at MongoDB.Driver.ClusterRegistry.GetOrCreateCluster(ClusterKey clusterKey) at MongoDB.Driver.MongoClient..ctor(MongoClientSettings settings) at Treolan.Catalog.Providers.BaseDataProvider..ctor(IAppSettings appSettings) in D:\Projects\TreolanCatalog\Treolan\Treolan.Catalog.Providers\BaseDataProvider.cs:line 39 at Treolan.Catalog.Providers.Categories.CategoriesProvider..ctor(IAppSettings appSettings) in D:\Projects\TreolanCatalog\Treolan\Treolan.Catalog.Providers\Categories\CategoriesProvider.cs:line 22 at Treolan.Catalog.WebApi.Controllers.CategoriesController.<>c.<.ctor>b__6_0() in D:\Projects\TreolanCatalog\Treolan\Treolan.Catalog.WebApi2\Controllers\CategoriesController.cs:line 31 at Treolan.Catalog.WebApi.Controllers.CategoriesController.<Get>d__7.MoveNext() in D:\Projects\TreolanCatalog\Treolan\Treolan.Catalog.WebApi2\Controllers\CategoriesController.cs:line 48
已尝试的解决方法
- 我曾查找过类似问题,发现其他开发者是在Azure上使用Application Insight时遇到的,但我并未使用Application Insight或Azure。
- 尝试更换MongoDB.Driver的版本为2.5.0和2.6.1,问题依然存在。
恳请各位帮忙分析并解决这个问题!
内容的提问来源于stack exchange,提问作者Alexander Poplooukhin
相关产品推荐
相关产品推荐

