应用程序启动前的初始化方法...运行WebActivatorEx.ActivationManager-调用的目标引发了异常

Hei*_*ich 5 c# asp.net-mvc unity-container visual-studio azure-web-sites

通常在更改了运行的ASP.NET MVC Azure Web服务应用程序上的web.config之后,我总是收到此错误。它将第一次运行良好,但是在更改web.config之后重新编译后,通常会出现这种情况。我认为有时是通过启动和停止Web应用程序来实现的。使它消失的唯一方法是再次将应用程序从Visual Studio发布到Azure。

Method not found: 'Microsoft.Practices.Unity.IUnityContainer MyProject.Core.ContainerManager.GetConfiguredContainer()'.    

The pre-application start initialization method Run on type WebActivatorEx.ActivationManager threw an exception with the following error message: Exception has been thrown by the target of an invocation

Source File: D:\MyProject-master\src\MyProject.Web\App_Start\UnityMvcActivator.cs    Line: 73 
Run Code Online (Sandbox Code Playgroud)

堆栈跟踪

MissingMethodException: Method not found:   
'Microsoft.Practices.Unity.IUnityContainer 
MyProject.Core.ContainerManager.GetConfiguredContainer()'.]
MyProject.Web.App_Start.UnityWebActivator.Start() in D:\MyProject-master\src\MyProject.Web\App_Start\UnityMvcActivator.cs:73

[TargetInvocationException: Exception has been thrown by the target of an invocation.]
   System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor) +0
   System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments) +87
System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) +101
   WebActivatorEx.BaseActivationMethodAttribute.InvokeMethod() +73
   WebActivatorEx.ActivationManager.RunActivationMethods(Boolean designerMode) +350
   WebActivatorEx.ActivationManager.Run() +78

[InvalidOperationException: The pre-application start initialization method Run on type WebActivatorEx.ActivationManager threw an exception with the following error message: Exception has been thrown by the target of an invocation..]

 System.Web.Compilation.BuildManager.InvokePreStartInitMethodsCore(ICollection`1 methods, Func`1 setHostingEnvironmentCultures) +615
System.Web.Compilation.BuildManager.InvokePreStartInitMethods(ICollection`1 methods) +141


   System.Web.Compilation.BuildManager.CallPreStartInitMethods(String preStartInitListPath, Boolean& isRefAssemblyLoaded) +102
   System.Web.Compilation.BuildManager.ExecutePreAppStart() +157
   System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +549

[HttpException (0x80004005): The pre-application start initialization method Run on type WebActivatorEx.ActivationManager threw an exception with the following error message: Exception has been thrown by the target of an invocation..]
 System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +10075124
 System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +95


 System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +254
Run Code Online (Sandbox Code Playgroud)

这个问题似乎非常接近我的问题,但是我还没有得到这个解决方案的帮助,我的解决方案中有两个使用该RegisterTypes方法的项目:

接口,无法在Unity配置上构建

这些问题是相关的,但不完全是这个问题:

/sf/ask/1475486631/

激活过程中的ActivationManager异常?

NuGet的Unity Bootstrapper在App_Start上引发错误

编辑:如果我在部署过程中将应用程序合并到单个程序集中,该问题似乎不再发生。

小智 1

安装包 Microsoft.AspNet.WebHelpers