2012-04-04 2 views
13

appharbor에 배포 된 MVC 3 프로젝트에서 Ninject를 사용하고 있습니다. 응용 프로그램이 시작될 때 예외가 발생하고 Ninject가 원인 인 것처럼 보였으 나 거기에서 어떤 대답도 찾을 수 없다는 것을 알았습니다. - 그래서 제발 도와주세요. :)appharbor에서 응용 프로그램 시작시 Ninject가 충돌 함

완전한 예외를 추가하려고합니다. 여기 :

Server Error in '/' Application. 

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.] 
    NewRelic.Agent.Core.AgentShim.GetTracer(String tracerFactoryName, UInt32 level, String metricName, String assemblyName, String className, String methodName, String argumentSignature, Object invocationTarget) +51 
    System.AppDomain.CreateDomain(String friendlyName, Evidence securityInfo, AppDomainSetup info) +99 
    Ninject.Modules.AssemblyNameRetriever.CreateTemporaryAppDomain() in c:\Projects\Ninject\ninject\src\Ninject\Modules\AssemblyNameRetriever.cs:68 
    Ninject.Modules.AssemblyNameRetriever.GetAssemblyNames(IEnumerable`1 filenames, Predicate`1 filter) in c:\Projects\Ninject\ninject\src\Ninject\Modules\AssemblyNameRetriever.cs:47 
    Ninject.Modules.CompiledModuleLoaderPlugin.LoadModules(IEnumerable`1 filenames) in c:\Projects\Ninject\ninject\src\Ninject\Modules\CompiledModuleLoaderPlugin.cs:81 
    Ninject.Modules.ModuleLoader.LoadModules(IEnumerable`1 patterns) in c:\Projects\Ninject\ninject\src\Ninject\Modules\ModuleLoader.cs:60 
    Ninject.KernelBase.Load(IEnumerable`1 filePatterns) in c:\Projects\Ninject\ninject\src\Ninject\KernelBase.cs:236 
    Ninject.KernelBase..ctor(IComponentContainer components, INinjectSettings settings, INinjectModule[] modules) in c:\Projects\Ninject\ninject\src\Ninject\KernelBase.cs:97 
    Ninject.KernelBase..ctor(INinjectModule[] modules) in c:\Projects\Ninject\ninject\src\Ninject\KernelBase.cs:57 
    Ninject.StandardKernel..ctor(INinjectModule[] modules) in c:\Projects\Ninject\ninject\src\Ninject\StandardKernel.cs:46 
    Checkin.App_Start.NinjectWebCommon.CreateKernel() in d:\temp\44uvjuob.32m\input\Checkin\App_Start\NinjectWebCommon.cs:43 
    Ninject.Web.Common.Bootstrapper.Initialize(Func`1 createKernelCallback) in c:\Projects\Ninject\Ninject.Web.Common\src\Ninject.Web.Common\Bootstrapper.cs:50 
    Checkin.App_Start.NinjectWebCommon.Start() in d:\temp\44uvjuob.32m\input\Checkin\App_Start\NinjectWebCommon.cs:26 

[TargetInvocationException: Exception has been thrown by the target of an invocation.] 
    System.RuntimeMethodHandle._InvokeMethodFast(IRuntimeMethodInfo method, Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeType typeOwner) +0 
    System.RuntimeMethodHandle.InvokeMethodFast(IRuntimeMethodInfo method, Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeType typeOwner) +69 
    System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks) +242 
    System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) +21 
    System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters) +19 
    WebActivator.BaseActivationMethodAttribute.InvokeMethod() +223 
    WebActivator.ActivationManager.RunActivationMethods() +493 
    WebActivator.ActivationManager.RunPreStartMethods() +28 
    WebActivator.ActivationManager.Run() +55 

[InvalidOperationException: The pre-application start initialization method Run on type WebActivator.ActivationManager threw an exception with the following error message: Exception has been thrown by the target of an invocation..] 
    System.Web.Compilation.BuildManager.InvokePreStartInitMethods(ICollection`1 methods) +377 
    System.Web.Compilation.BuildManager.CallPreStartInitMethods() +267 
    System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager, IApplicationHost appHost, IConfigMapPathFactory configMapPathFactory, HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel, Exception appDomainCreationException) +690 

[HttpException (0x80004005): The pre-application start initialization method Run on type WebActivator.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) +532 
    System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +90 
    System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +172 

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

페이지를 다시로드하면 예외가 사라집니다. 이것은 필터 Ninject에 사용하여 함께 할 수있는 뭔가가있을 수 있습니다 :

this.BindFilter<AdminAuthorizationAttribute>(FilterScope.Controller, -100) 
    .When((context, ad) => context.RouteData.DataTokens["area"] != null && 
      ((string)context.RouteData.DataTokens["area"]).ToLower() == "admin" && 
      ((string)context.RouteData.Values["controller"]).ToLower() != "login"); 
+0

심지어 저는이 문제에 당황했습니다. 그 Ninject가 충돌하는 이유는 무엇입니까? 필터를 꺼내면 사라질까요? – Mrchief

+0

또한이 오류가 발생합니다. 또한 appharbor 및 Windows 2008 서버에 새 유적이 설치된 상태로 새 유적이 될 수 있습니다. ninject 2.2와 3.0 모두. – terjetyl

+0

스택 추적 ('NewRelic.Agent.Core.AgentShim.GetTracer')에서 문제를 일으키는 NewRelic 인 것 같습니다 ... – nemesv

답변

13

문제가 Ninject에 의해 발생되지 않습니다. 그것은 NewRelic.Agent입니다 .Core.AgentShim (AppHarbor에서 사용)이 범인입니다.

stacktrace를 살펴 보았지만 Ninject의 자동 확장 기능을 비활성화하고 수동으로로드하여이 문제를 해결할 수 있다고 생각합니다.

var kernel = new StandardKernel(new NinjectSettings { LoadExtensions = false }) 
kernel.Load(new Ninject.Web.Mvc.MvcModule()); // same for all other extension modules 
+0

나는 이것을 시도했지만, 내 문제를 해결하지 못했습니다. LoadExtensions = false 인 경우에도 여전히 예외가 발생합니다. –

+0

@JessChadwick 이것은 질문의 stacktrace에 대한 해결 방법 일뿐입니다. 위와 똑같이 완료되면 스택 추적을 해결합니다. 다른 문제가 있거나 커널을 만든 후에 LoadExtension을 false로 설정하고 있습니다 (kernel.Settings.LoadExtensions = false). 이것은 작동하지 않습니다. 다른 문제가있는 경우 AppHarbor이 문제를 해결할 때까지 기다려야 할 것입니다. –

+0

@RemoGloor, nope - 정확히 동일한 스택 추적을 가져 와서 위의 예와 같이 LoadExtensions 속성을 설정했습니다. AppHarbor가 고칠 때까지 기다려야 할 것처럼 보입니다. –

1

임시로 New Relic 애드온을 비활성화하고 AppHarbor 서버에서 새 유적 에이전트를 제거했습니다. 플랫폼에서 실행되는 응용 프로그램에서 더 이상 문제를 일으키지 않으면 New Relic을 다시 추가합니다.

관련 문제