This project is read-only.

errors "Value cannot be null. Parameter name: serviceKey"

Nov 21, 2010 at 7:29 PM

Hi all,

I experience error when I added my own module to the Orchard source code in VS2010.

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: 

[ArgumentNullException: Value cannot be null.
Parameter name: serviceKey]
   Autofac.Util.Enforce.ArgumentNotNull(T value, String name) +115
   Autofac.Core.KeyedService..ctor(Object serviceKey, Type serviceType) +58
   Orchard.Mvc.OrchardControllerFactory.TryResolve(WorkContext workContext, Object serviceKey, T& instance) +184
   Orchard.Mvc.OrchardControllerFactory.GetControllerInstance(RequestContext requestContext, Type controllerType) +107
   System.Web.Mvc.DefaultControllerFactory.CreateController(RequestContext requestContext, String controllerName) +74
   System.Web.Mvc.MvcHandler.ProcessRequestInit(HttpContextBase httpContext, IController& controller, IControllerFactory& factory) +196
   System.Web.Mvc.<>c__DisplayClass6.<BeginProcessRequest>b__2() +49
   System.Web.Mvc.<>c__DisplayClassb`1.<ProcessInApplicationTrust>b__a() +13
   System.Web.Mvc.SecurityUtil.<GetCallInAppTrustThunk>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
   Orchard.Mvc.Routes.HttpAsyncHandler.BeginProcessRequest(HttpContext context, AsyncCallback cb, Object extraData) +183
   System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +8841400
   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +184


It does not make sense to me.

Any one has any clue?

Jan 26, 2011 at 8:58 PM

I can confirm also that I am getting this exception from latest source code but not from package zip in downloads. I saw also that there is already Work Item in Issue Tracker for this as "Value cannot be null. Parameter name: serviceKey in Gallery" Item # 17202.

I saw additional exception in context of the exception, “This operation requires IIS Integrated Pipeline mode.” As workaround if you publish your solution to local IIS and debug maybe it will work, but i have not tested this workaround yet.

I added screenshot of this additional exception in this Work Item.


Jan 27, 2011 at 2:10 AM

It looks like you're trying to inject something into a controller that hasn't been picked up by AutoFac for resolution.  Make sure that any custom services you're trying to inject are using interfaces which inherit from IDependency; and also make sure that there's a valid implementation class available.

Jan 27, 2011 at 6:59 PM
Edited Jan 27, 2011 at 7:12 PM


I just downloaded the lastest source code Change Set 948821676e75 Jan 19 at 12:16 AM. Built by using the scripts provided, ran the solution and got the error, pretty much same way as described on Item 17202. Perhaps something missing in latest source code?


Jan 27, 2011 at 7:27 PM

As far as I can tell the latest is fine. Probably something with your environment. Please check that you're running in a 4.0 pool for example and that you don't have old versions of WebMatrix or MVC on that box.

Jan 27, 2011 at 7:41 PM

I have clean environment, no WebMatrix installed, MVC 2 / MVC 3 RTM installed. VS 2010 is currently SP1 beta level, as well as .Net 4.0.

I downloaded latest Source code or change set 19 Feb. I removed the read-only attributes for files, compiled the source by use of ClickToBuild.cmd and opened the compiled solution in VS2010 and run it by use of Ctrl+F5. Set the name, admin user/psw, and choice of using SQLCE. Went to dashboard and got the error as described on previous work item. Any ideas what can be wrong? If i continue the project and ignore the exception the admin dashboard page shows up.


Feb 1, 2011 at 4:12 PM

Same here I get the error when clicked Gallery>Modules. I am debugging from VS 2010.

Feb 1, 2011 at 10:03 PM

i got this error when i create custom content type following the instruction, it is 1.0.20 sr code, nothing change

Feb 1, 2011 at 11:29 PM

For the ones who are getting this error, could you correct the href in the file: src/Orchard.Web/Themes/TheAdmin/Views/Layout.cshtml.

To have:

+    RegisterLink(new LinkEntry { Condition = "lte IE 8", Rel = "stylesheet", Type = "text/css", Href = Url.Content("~/Themes/TheAdmin/Styles/ie.css") }.AddAttribute("media", "screen, projection"));
+    RegisterLink(new LinkEntry { Condition = "lte IE 6", Rel = "stylesheet", Type = "text/css", Href = Url.Content("~/Themes/TheAdmin/Styles/ie6.css") }.AddAttribute("media", "screen, projection"));

instead of:

-    RegisterLink(new LinkEntry { Condition = "lte IE 8", Rel = "stylesheet", Type = "text/css", Href = Url.Content("../Styles/ie.css") }.AddAttribute("media", "screen, projection"));
-    RegisterLink(new LinkEntry { Condition = "lte IE 6", Rel = "stylesheet", Type = "text/css", Href = Url.Content("../Styles/ie6.css") }.AddAttribute("media", "screen, projection"));

Mar 2, 2011 at 7:32 AM

I get the same error, but only in IE.

I have IE9 RC installed.

Everything works fine in FireFox and Chrome.