首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >WebActivatorEx在应用程序启动时导致ArgumentException

WebActivatorEx在应用程序启动时导致ArgumentException
EN

Stack Overflow用户
提问于 2015-06-25 15:24:27
回答 2查看 6.5K关注 0票数 4

在安装了ArgumentException nuget包之后,当我试图访问一个页面时,我一直得到下面的WebActivatorEx。

代码语言:javascript
运行
复制
Server Error in '/PharmaDotnet/ux' Application.
The type Pharma.Mvc.Startup doesn't have a static method named Configuration
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.ArgumentException: The type Pharma.Mvc.Startup doesn't have a static method named Configuration

Source Error:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

Stack Trace:


[ArgumentException: The type Pharma.Mvc.Startup doesn't have a static method named Configuration]
   WebActivatorEx.BaseActivationMethodAttribute.InvokeMethod() +166
   WebActivatorEx.ActivationManager.RunActivationMethods(Boolean designerMode) +445
   WebActivatorEx.ActivationManager.Run() +105

[InvalidOperationException: The pre-application start initialization method Run on type WebActivatorEx.ActivationManager threw an exception with the following error message: The type Pharma.Mvc.Startup doesn't have a static method named Configuration.]
   System.Web.Compilation.BuildManager.InvokePreStartInitMethodsCore(ICollection`1 methods, Func`1 setHostingEnvironmentCultures) +12981643
   System.Web.Compilation.BuildManager.InvokePreStartInitMethods(ICollection`1 methods) +12981352
   System.Web.Compilation.BuildManager.CallPreStartInitMethods(String preStartInitListPath, Boolean& isRefAssemblyLoaded) +280
   System.Web.Compilation.BuildManager.ExecutePreAppStart() +172
   System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +1151

[HttpException (0x80004005): The pre-application start initialization method Run on type WebActivatorEx.ActivationManager threw an exception with the following error message: The type Pharma.Mvc.Startup doesn't have a static method named Configuration.]
   System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +12980692
   System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +159
   System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +12820285


Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.34249 

如果我删除了WebActivatorEx包,一切都会再次正常工作,但我需要使用WebActivatorEx才能使用DI。

我在网上找不到任何关于这个问题的建议。我尝试使用一个名为Startup的静态方法在Pharma.Mvc命名空间中创建一个Configuration类,这个方法似乎没有解决这个问题。

而且,在我安装包之前,没有Pharma.Mvc命名空间,也没有Startup类。所以我真的很困惑为什么会发生这种事。

在构建应用程序时,我的目标是ASP.NET 4.5.1框架,但是我注意到,在底部的堆栈跟踪中,它读取Microsoft .NET 4 Framework Version:4.0.30319,我不确定这是否正确。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2015-06-26 15:48:57

它原来是bin文件夹中的一个旧程序集,该程序集不再被引用,从而导致问题。

票数 5
EN

Stack Overflow用户

发布于 2016-10-14 20:44:26

我使用带有WebApi的OWIN中间件,因此需要一个具有以下程序集属性程序集的启动类: OwinStartup(typeof( Startup ))

我还为WebApi使用Swagger接口,并通过nuget包安装它。安装添加了具有以下程序集属性程序集的PreApplicationStartMethod(typeof(SwaggerConfig),类: SwaggerConfig“寄存器”)

程序集属性在启动WebApi时导致此异常。我从SwaggerConfig类中删除了程序集属性,一切都正常。

票数 15
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/31054522

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档