Note that there are some explanatory texts on larger screens.

plurals
  1. PONLog Failing on Release Mode in IIS7
    text
    copied!<p>EDIT: As Kirk Woll correctly pointed out, the issue is NLog, not with NInject. So let me rephrase the issue:</p> <p>EDIT2: Now that I knew it was NLog + an IoC problem, I found the solution at <a href="https://stackoverflow.com/questions/3438162/asp-net-mvc2-ninject-nlog-shared-hosting-nullreferenceexception">ASP.NET MVC2 + Ninject + NLog (+ shared hosting?) = NullReferenceException</a></p> <p>I have a project that is using NInject to inject an NLogger class via an ILogger interface into all of my controllers. Steven, to answer your question to keep my web.config clean, I have used an NLog.Config file to separate out that configuration.</p> <p>When I target IIS7 in Debug mode, the code works correctly, but in Release Mode I get the below stack trace.</p> <p>If anyone has any idea why in Debug Mode the code would work, and why in Release it wouldn't, it'd be much appreciated. I've also included my NLog Config File below.</p> <pre><code>&lt;?xml version="1.0"?&gt; &lt;nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"&gt; &lt;targets&gt; &lt;target name="console" xsi:type="ColoredConsole" layout="${date:format=HH\:mm\:ss}|${level}|${stacktrace}|${message}" /&gt; &lt;target name="file" xsi:type="File" fileName="${basedir}/App_Data//Logs/site.log" layout="${date}: ${message}" /&gt; &lt;target name="eventlog" xsi:type="EventLog" source="Template" log="Application" layout="${date}: ${message} ${stacktrace}" /&gt; &lt;/targets&gt; &lt;rules&gt; &lt;logger name="*" minlevel="Info" writeTo="file" /&gt; &lt;logger name="*" minlevel="Fatal" writeTo="eventlog" /&gt; &lt;/rules&gt; &lt;/nlog&gt; </code></pre> <p>Stack Trace:</p> <pre><code>[NullReferenceException: Object reference not set to an instance of an object.] NLog.LogManager.GetCurrentClassLogger() +84 DynamicInjectorc5f536e7a4564738b2e779e62f9c20c7(Object[] ) +40 Ninject.Activation.Providers.StandardProvider.Create(IContext context) in c:\Projects\Ninject\Maintenance2.2\ninject\src\Ninject\Activation\Providers\StandardProvider.cs:81 Ninject.Activation.Context.Resolve() in c:\Projects\Ninject\Maintenance2.2\ninject\src\Ninject\Activation\Context.cs:157 Ninject.KernelBase.&lt;Resolve&gt;b__7(IContext context) in c:\Projects\Ninject\Maintenance2.2\ninject\src\Ninject\KernelBase.cs:375 System.Linq.&lt;&gt;c__DisplayClass12`3.&lt;CombineSelectors&gt;b__11(TSource x) +32 System.Linq.WhereSelectEnumerableIterator`2.MoveNext() +151 System.Linq.Enumerable.SingleOrDefault(IEnumerable`1 source) +4222965 Ninject.Planning.Targets.Target`1.GetValue(Type service, IContext parent) in c:\Projects\Ninject\Maintenance2.2\ninject\src\Ninject\Planning\Targets\Target.cs:179 Ninject.Planning.Targets.Target`1.ResolveWithin(IContext parent) in c:\Projects\Ninject\Maintenance2.2\ninject\src\Ninject\Planning\Targets\Target.cs:147 Ninject.Activation.Providers.StandardProvider.GetValue(IContext context, ITarget target) in c:\Projects\Ninject\Maintenance2.2\ninject\src\Ninject\Activation\Providers\StandardProvider.cs:97 Ninject.Activation.Providers.&lt;&gt;c__DisplayClass2.&lt;Create&gt;b__1(ITarget target) in c:\Projects\Ninject\Maintenance2.2\ninject\src\Ninject\Activation\Providers\StandardProvider.cs:81 System.Linq.WhereSelectArrayIterator`2.MoveNext() +85 System.Linq.Buffer`1..ctor(IEnumerable`1 source) +217 System.Linq.Enumerable.ToArray(IEnumerable`1 source) +78 Ninject.Activation.Providers.StandardProvider.Create(IContext context) in c:\Projects\Ninject\Maintenance2.2\ninject\src\Ninject\Activation\Providers\StandardProvider.cs:81 Ninject.Activation.Context.Resolve() in c:\Projects\Ninject\Maintenance2.2\ninject\src\Ninject\Activation\Context.cs:157 Ninject.KernelBase.&lt;Resolve&gt;b__7(IContext context) in c:\Projects\Ninject\Maintenance2.2\ninject\src\Ninject\KernelBase.cs:375 System.Linq.&lt;&gt;c__DisplayClass12`3.&lt;CombineSelectors&gt;b__11(TSource x) +32 System.Linq.WhereSelectEnumerableIterator`2.MoveNext() +151 System.Linq.Enumerable.SingleOrDefault(IEnumerable`1 source) +4222965 Ninject.Web.Mvc.NinjectDependencyResolver.GetService(Type serviceType) in c:\Projects\Ninject\Maintenance2.2\ninject.web.mvc\mvc3\src\Ninject.Web.Mvc\NinjectDependencyResolver.cs:56 System.Web.Mvc.DefaultControllerActivator.Create(RequestContext requestContext, Type controllerType) +51 [InvalidOperationException: An error occurred when trying to create a controller of type 'BossP.Controllers.HomeController'. Make sure that the controller has a parameterless public constructor.] System.Web.Mvc.DefaultControllerActivator.Create(RequestContext requestContext, Type controllerType) +182 System.Web.Mvc.DefaultControllerFactory.GetControllerInstance(RequestContext requestContext, Type controllerType) +80 System.Web.Mvc.DefaultControllerFactory.CreateController(RequestContext requestContext, String controllerName) +74 System.Web.Mvc.MvcHandler.ProcessRequestInit(HttpContextBase httpContext, IController&amp; controller, IControllerFactory&amp; factory) +232 System.Web.Mvc.&lt;&gt;c__DisplayClass6.&lt;BeginProcessRequest&gt;b__2() +49 System.Web.Mvc.&lt;&gt;c__DisplayClassb`1.&lt;ProcessInApplicationTrust&gt;b__a() +13 System.Web.Mvc.SecurityUtil.&lt;GetCallInAppTrustThunk&gt;b__0(Action f) +7 System.Web.Mvc.SecurityUtil.ProcessInApplicationTrust(Action action) +22 System.Web.Mvc.SecurityUtil.ProcessInApplicationTrust(Func`1 func) +124 System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContextBase httpContext, AsyncCallback callback, Object state) +98 System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContext httpContext, AsyncCallback callback, Object state) +50 System.Web.Mvc.MvcHandler.System.Web.IHttpAsyncHandler.BeginProcessRequest(HttpContext context, AsyncCallback cb, Object extraData) +16 System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +8963444 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean&amp; completedSynchronously) +184 </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload