Мое веб-приложение использует Unity для DI.Другой раздел веб-приложения использует MEF.Код отлично работает в однопоточном сеансе.Но как только я нажимаю на одну и ту же ссылку из двух разных веб-сессий (CHrome и FIrefox).Я не уверен, является ли это проблемой циклического референсного цикла или проблемой многопоточности ... Она прекрасно работает в одном сеансе, эта ошибка возникает только при нажатии на одну и ту же ссылку в двух разных сеансах.
Я получаю следующую ошибку:
Exception information:
Exception type: ResolutionFailedException
Exception message: Resolution of the dependency failed, type = "MefContrib.Integration.Unity.Extensions.TypeRegistrationTrackerExtension", name = "(none)".
Exception occurred while: while resolving.
Exception is: InvalidOperationException - Currently composing another batch in this ComposablePartExportProvider. Only one batch can be composed at a time.
Подробнее об ошибке:
Server Error in '/' Application.
GetExportedValue cannot be called before prerequisite import 'MyApp.Core.Services.RuleService..ctor (Parameter="productService", ContractName="MyApp.Core.Services.IProductService")' has been set.
InvalidOperationException: GetExportedValue cannot be called before prerequisite import 'MyApp.Core.Services.RuleService..ctor (Parameter="productService", ContractName="MyApp.Core.Services.IProductService")' has been set.]
System.ComponentModel.Composition.ReflectionModel.ReflectionComposablePart.EnsureGettable() +422
System.ComponentModel.Composition.ReflectionModel.ReflectionComposablePart.GetExportedValue(ExportDefinition definition) +208
System.ComponentModel.Composition.Hosting.CompositionServices.GetExportedValueFromComposedPart(ImportEngine engine, ComposablePart part, ExportDefinition definition) +131
System.ComponentModel.Composition.Hosting.CatalogExportProvider.GetExportedValue(ComposablePart part, ExportDefinition export, Boolean isSharedPart) +102
System.ComponentModel.Composition.Hosting.CatalogExport.GetExportedValueCore() +148
System.ComponentModel.Composition.Primitives.Export.get_Value() +76
System.ComponentModel.Composition.ReflectionModel.ImportingItem.Cast(Type type, Export export) +63
System.ComponentModel.Composition.ReflectionModel.ImportingItem.CastSingleExportToImportType(Type type, Export export) +149
System.ComponentModel.Composition.ReflectionModel.ImportingItem.CastExportsToSingleImportType(Export[] exports) +163
System.ComponentModel.Composition.ReflectionModel.ImportingItem.CastExportsToImportType(Export[] exports) +118
System.ComponentModel.Composition.ReflectionModel.ReflectionComposablePart.SetImport(ImportingItem item, Export[] exports) +74
System.ComponentModel.Composition.ReflectionModel.ReflectionComposablePart.SetImport(ImportDefinition definition, IEnumerable`1 exports) +230
System.ComponentModel.Composition.Hosting.PartManager.TrySetImport(ImportDefinition import, IEnumerable`1 exports) +91
System.ComponentModel.Composition.Hosting.ImportEngine.TrySatisfyImportSubset(PartManager partManager, IEnumerable`1 imports, AtomicComposition atomicComposition) +449
System.ComponentModel.Composition.Hosting.ImportEngine.TrySatisfyImportsStateMachine(PartManager partManager, ComposablePart part) +571
System.ComponentModel.Composition.Hosting.ImportEngine.TrySatisfyImports(PartManager partManager, ComposablePart part, Boolean shouldTrackImports) +277
System.ComponentModel.Composition.Hosting.ImportEngine.SatisfyImports(ComposablePart part) +201
System.ComponentModel.Composition.Hosting.CompositionServices.GetExportedValueFromComposedPart(ImportEngine engine, ComposablePart part, ExportDefinition definition) +77
System.ComponentModel.Composition.Hosting.CatalogExportProvider.GetExportedValue(ComposablePart part, ExportDefinition export, Boolean isSharedPart) +102
System.ComponentModel.Composition.Hosting.CatalogExport.GetExportedValueCore() +148
System.ComponentModel.Composition.Primitives.Export.get_Value() +76
System.ComponentModel.Composition.ExportServices.GetCastedExportedValue(Export export) +54
System.ComponentModel.Composition.<>c__DisplayClass10`2.<CreateSemiStronglyTypedLazy>b__d() +107
System.Lazy`1.get_Value() +136
MefContrib.Integration.Unity.Strategies.CompositionStrategy.PreBuildUp(IBuilderContext context) +361
Microsoft.Practices.ObjectBuilder2.StrategyChain.ExecuteBuildUp(IBuilderContext context) in e:\Builds\Unity\UnityTemp\Compile\Unity\Unity\Src\ObjectBuilder\Strategies\StrategyChain.cs:110
Microsoft.Practices.ObjectBuilder2.BuilderContext.NewBuildUp(NamedTypeBuildKey newBuildKey) in e:\Builds\Unity\UnityTemp\Compile\Unity\Unity\Src\ObjectBuilder\BuilderContext.cs:215
Microsoft.Practices.Unity.ObjectBuilder.NamedTypeDependencyResolverPolicy.Resolve(IBuilderContext context) in e:\Builds\Unity\UnityTemp\Compile\Unity\Unity\Src\ObjectBuilderCustomization\NamedTypeDependencyResolverPolicy.cs:51
BuildUp_MyApp.Core.Services.ClientService(IBuilderContext ) +591
Microsoft.Practices.ObjectBuilder2.DynamicMethodBuildPlan.BuildUp(IBuilderContext context) in e:\Builds\Unity\UnityTemp\Compile\Unity\Unity\Src\ObjectBuilder\Strategies\BuildPlan\DynamicMethod\DynamicMethodBuildPlan.cs:37
Microsoft.Practices.ObjectBuilder2.BuildPlanStrategy.PreBuildUp(IBuilderContext context) in e:\Builds\Unity\UnityTemp\Compile\Unity\Unity\Src\ObjectBuilder\Strategies\BuildPlan\BuildPlanStrategy.cs:43
Microsoft.Practices.ObjectBuilder2.StrategyChain.ExecuteBuildUp(IBuilderContext context) in e:\Builds\Unity\UnityTemp\Compile\Unity\Unity\Src\ObjectBuilder\Strategies\StrategyChain.cs:110
Microsoft.Practices.Unity.UnityContainer.DoBuildUp(Type t, Object existing, String name, IEnumerable`1 resolverOverrides) in e:\Builds\Unity\UnityTemp\Compile\Unity\Unity\Src\UnityContainer.cs:511
[ResolutionFailedException: Resolution of the dependency failed, type = "MyApp.Core.Services.ClientService", name = "IFClientService".
Exception occurred while: while resolving.
Exception is: InvalidOperationException - GetExportedValue cannot be called before prerequisite import 'MyApp.Core.Services.RuleService..ctor (Parameter="productService", ContractName="MyApp.Core.Services.IProductService")' has been set.
-----------------------------------------------
At the time of the exception, the container was:
Resolving MyApp.Core.Services.ClientService,IFClientService
Resolving parameter "companyClientValidator" of constructor MyApp.Core.Services.ClientService(MyApp.Core.Repository.IClientRepository repository, MyApp.Core.Validators.IClientValidator validator, MyApp.Core.Validators.IChildClientValidator childClientValidator, MyApp.Core.Services.IReferenceService referenceService, MyApp.Core.Services.IProductService productService, MyApp.Core.Services.IOccupationService occupationService, MyApp.Core.Services.IAdviserService adviserService, MyApp.Core.Validators.ICompanyClientValidator companyClientValidator, MyApp.Core.Repository.IAddressRepository addressRepository)
Resolving MyApp.Core.Validators.ICompanyClientValidator,(none)
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidOperationException: GetExportedValue cannot be called before prerequisite import 'MyApp.Core.Services.RuleService..ctor (Parameter="productService", ContractName="MyApp.Core.Services.IProductService")' has been set.