我有一个 Swagger 完美运行的开发环境。
我采用相同的代码并将其部署到另一个环境,但出现错误:
[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) +523
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +118
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +704
我确信这是一个环境问题。我尝试了我删除的所有内容
[assembly: PreApplicationStartMethod(typeof(SwaggerConfig), "Register")]
并将其替换为
SwaggerConfig.Register();
GlobalConfiguration.Configure(WebApiConfig.Register);
当我部署刚刚在另一个环境中工作的相同代码时,我仍然会遇到同样的错误。
这是我需要允许 IIS 触发 PreApplicationStartMethod 的 IIS 设置吗?