【问题标题】:Deployment - Object reference not set to an instance of an object部署 - 对象引用未设置为对象的实例
【发布时间】:2012-05-09 13:17:06
【问题描述】:

我的 ASP.NET MVC 3 应用程序在我的本地计算机上运行良好(并且在我部署它时通常运行良好),但在这种情况下我收到以下错误。服务器是带有 IIS7 的 windows 2008 R2

编辑:ILoggingService 和 IConfigSettings 都被 Ninject 绑定在单例范围内(如果有帮助)

有人知道我应该寻找什么吗?

Object reference not set to an instance of an object. 
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.NullReferenceException: Object reference not set to an instance of an object.

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: 


[NullReferenceException: Object reference not set to an instance of an object.]
DataPortal.Models.Repositories.KpiRepository..ctor(ILoggingService ls, IConfigSettings configSettings) +1295
DynamicInjector3f592a0195c345d8a7d555c4c4085e12(Object[] ) +128
Ninject.Activation.Context.Resolve() +279
System.Linq.WhereSelectEnumerableIterator`2.MoveNext() +237
System.Linq.Enumerable.SingleOrDefault(IEnumerable`1 source) +298
System.Linq.WhereSelectArrayIterator`2.MoveNext() +109
System.Linq.Buffer`1..ctor(IEnumerable`1 source) +487
System.Linq.Enumerable.ToArray(IEnumerable`1 source) +103
Ninject.Activation.Providers.StandardProvider.Create(IContext context) +479
Ninject.Activation.Context.Resolve() +279
System.Linq.WhereSelectEnumerableIterator`2.MoveNext() +237
System.Linq.Enumerable.SingleOrDefault(IEnumerable`1 source) +298
System.Web.Mvc.DefaultControllerActivator.Create(RequestContext requestContext, Type controllerType) +67

[InvalidOperationException: An error occurred when trying to create a controller of type 'DataPortal.Controllers.KpiController'. Make sure that the controller has a parameterless public constructor.]
System.Web.Mvc.DefaultControllerActivator.Create(RequestContext requestContext, Type controllerType) +247
System.Web.Mvc.DefaultControllerFactory.CreateController(RequestContext requestContext, String controllerName) +85
System.Web.Mvc.MvcHandler.ProcessRequestInit(HttpContextBase httpContext, IController& controller, IControllerFactory& factory) +280
System.Web.Mvc.<>c__DisplayClass6.<BeginProcessRequest>b__2() +66
System.Web.Mvc.<>c__DisplayClassb`1.<ProcessInApplicationTrust>b__a() +19
System.Web.Mvc.SecurityUtil.ProcessInApplicationTrust(Func`1 func) +161
       System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +405
 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +375

【问题讨论】:

  • 小问题:2008 R2 自带 IIS7.5

标签: asp.net-mvc asp.net-mvc-3 deployment


【解决方案1】:

这最终是一个依赖问题。该项目依赖于另一个尚未部署的项目。

【讨论】:

    【解决方案2】:

    您的参数之一“LoggingService 或 ConfigSettings”似乎未在您的 web.config 中正确配置。检查您以前的工作版本配置文件。

    【讨论】:

    • 我工作的本地副本和不工作的测试服务器副本上的 Web.config 完全相同
    • 由于您使用的是依赖注入,请确保您已将所有依赖的 dll 复制到部署位置的 bin 目录中。比较您的工作和非工作文件夹的 bin 目录。这可能会有所帮助。
    • 谢谢我已经这样做了。有趣的是,部署的位置比我的本地文件夹多一个文件
    • 那是什么文件应该不是问题。尝试以下两个选项 1. 重建并重新发布。 2.尝试将其部署到另一台机器上并查看。顺便说一句,您是否使用任何将其 dll 安装到 gac 中的第三方应用程序?您是否通过依赖注入引用任何此类 dll?如果是这样,请确保您将这些 dll 安装到已部署的服务器 GAC 中
    • 不同的文件是一个Oracle dll,无论如何都没有在应用程序的这一部分中使用。我将把它部署到另一台服务器上,看看效果如何。
    【解决方案3】:

    在某些情况下,它可能与数据库问题有关,例如:

    在没有正确异常处理的情况下返回空值的选择将导致相同的错误。因此,需要检查他的sql请求。

    【讨论】:

      猜你喜欢
      • 2021-10-27
      • 2011-01-22
      • 2020-06-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多