Updating from NOF4 to NOF5

Nov 4, 2012 at 10:57 PM

I was trying to update our NOF4 MVC application to NOF5. After I successfully installed NakedObjects.MVC 5.0 version, I run the application. It gave the error like below. Any advice on how I can fix this? Please help. Thanks very much.


Could not load type 'NakedObjects.Security.ITypeAuthoriser`1' from assembly 'NakedObjects.Helpers, Version=, Culture=neutral, PublicKeyToken=null'.

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.TypeLoadException: Could not load type 'NakedObjects.Security.ITypeAuthoriser`1' from assembly 'NakedObjects.Helpers, Version=, Culture=neutral, PublicKeyToken=null'.

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: 


[TypeLoadException: Could not load type 'NakedObjects.Security.ITypeAuthoriser`1' from assembly 'NakedObjects.Helpers, Version=, Culture=neutral, PublicKeyToken=null'.]

   NakedObjects.Core.Context.HttpContextContext.EnsureContextReady() +98

   NakedObjects.Core.Context.NakedObjectsContext.EnsureReady() +51

   NakedObjects.Web.Mvc.Controllers.NakedObjectsController..ctor() +50

   NakedObjects.Web.Mvc.Controllers.SystemControllerImpl..ctor() +43

   Sdm.App.Controllers.SystemController..ctor() +43


[TargetInvocationException: Exception has been thrown by the target of an invocation.]

   System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck) +0

   System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache) +98

   System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipVisibilityChecks, Boolean skipCheckThis, Boolean fillCache) +241

   System.Activator.CreateInstance(Type type, Boolean nonPublic) +69

   System.Activator.CreateInstance(Type type) +6

   NakedObjects.Web.Mvc.NakedObjectsDependencyResolver.GetService(Type serviceType) +251

   System.Web.Mvc.DefaultControllerActivator.Create(RequestContext requestContext, Type controllerType) +51


[InvalidOperationException: An error occurred when trying to create a controller of type 'Sdm.App.Controllers.SystemController'. 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& controller, IControllerFactory& factory) +218

   System.Web.Mvc.MvcHandler.BeginProcessRequest(HttpContextBase httpContext, AsyncCallback callback, Object state) +49

   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() +8968180

   System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +184


Nov 5, 2012 at 7:13 AM

My guess is that you have upgraded your Run project, but your Model project(s) is/are still using the previous version of the Naked Objects Programming Model -  with the result that there are two versions of the NakedObjects.Helpers assembly in memory.  So, using the NuGet Package Manager, just upgrade your Model project(s) to the latest version of the packages -  there should be no other changes required to your code.

Nov 5, 2012 at 5:25 PM

Thanks Richard, that worked after I upgrade all my model projects. Cheers. 

Nov 6, 2012 at 8:10 AM

Good.  I know that you have a lot of Model projects in your solution!  Are you aware that you can upgrade NuGet packages (e.g. the NakedObjects.ProgrammingModel) at Solution level  -  so that it upgrades all the projects in one go?  Just invoke Manage NuGet Packages on the solution icon.

Nov 6, 2012 at 8:21 AM
Cool. I did not know that. :)
Nov 6, 2012 at 9:26 AM

I didn't know that either. It will save me a lot of time in the future.  :-) Thanks very much.