C# 当应用程序池回收时,无法使用unity容器解析依赖关系
当应用程序池回收时,我面临一个无法解决的依赖性问题。 当我们再次回收时,它会正确解决。 我已经在下面的一些细节点写了日志C# 当应用程序池回收时,无法使用unity容器解析依赖关系,c#,iis,dependency-injection,unity-container,C#,Iis,Dependency Injection,Unity Container,当应用程序池回收时,我面临一个无法解决的依赖性问题。 当我们再次回收时,它会正确解决。 我已经在下面的一些细节点写了日志 The current type, MyApp.DataAccess.IDataAccess, is an interface and cannot be constructed. Are you missing a type mapping?\r At the time of the exception, the container was:\r\n\r\n Reso
The current type, MyApp.DataAccess.IDataAccess, is an interface and cannot be constructed. Are you missing a type mapping?\r
At the time of the exception, the container was:\r\n\r\n Resolving MyApp.DataAccess.IDataAccess,(none)\r\n","DBResponseId":0}
Microsoft.Practices.Unity.ResolutionFailedException
Resolution of the dependency failed, type = "MyApp.DataAccess.IDataAccess", name = "(none)".
Exception occurred while: while resolving.
Exception is: InvalidOperationException - The current type, MyApp.DataAccess.IDataAccess, is an interface and cannot be constructed. Are you missing a type mapping?
-----------------------------------------------
At the time of the exception, the container was:
Resolving MyApp.DataAccess.IDataAccess,(none)
at Microsoft.Practices.Unity.UnityContainer.DoBuildUp(Type t, Object existing, String name, IEnumerable`1 resolverOverrides)
at Microsoft.Practices.Unity.UnityContainer.Resolve(Type t, String name, ResolverOverride[] resolverOverrides)
at Microsoft.Practices.Unity.UnityContainerExtensions.Resolve[T](IUnityContainer container, ResolverOverride[] overrides)
at MyApp.Services.ServiceHelper.GetSession(String token, Boolean updateLastRequestTime) in E:\Application\MyAlert\Web\MyAlertCloud-Dev\Services\Services\ServiceHelper.cs:line 154
at MyApp.ServiceFacade.BaseServiceFacade`1.ExecuteService[TRequest,TResponse](Func`3 serviceFunc, TRequest request) in E:\Application\MyAlert\Web\MyAlertCloud-Dev\Services\Facade\ServiceFacade\BaseServiceFacade.cs:line 164
------------------------------ INNER LEVEL 1------------------------------
System.InvalidOperationException
The current type, MyApp.DataAccess.IDataAccess, is an interface and cannot be constructed. Are you missing a type mapping?
at Microsoft.Practices.ObjectBuilder2.DynamicMethodConstructorStrategy.ThrowForAttemptingToConstructInterface(IBuilderContext context)
at BuildUp_MyApp.DataAccess.IDataAccess(IBuilderContext )
at Microsoft.Practices.ObjectBuilder2.BuildPlanStrategy.PreBuildUp(IBuilderContext context)
at Microsoft.Practices.ObjectBuilder2.StrategyChain.ExecuteBuildUp(IBuilderContext context)
at Microsoft.Practices.Unity.UnityContainer.DoBuildUp(Type t, Object existing, String name, IEnumerable`1 resolverOverrides)
下面是如何在unity配置中完成配置
<typeAlias alias="IDataAccess" type="MyApp.DataAccess.IDataAccess, MyApp.DataAccess" />
<typeAlias alias="DataAccess" type="MyApp.DataAccess.DataAccess, MyApp.DataAccess" />
这种行为时断时续。这很奇怪