Orchard: Association references unmapped class: System.String

After making some changes in one of my modules, I started getting the following error whenever I opened Orchard CMS in a browser:

Server Error in ‘/orchard’ Application.


Association references unmapped class: System.String

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: NHibernate.MappingException: Association references unmapped class: System.String

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:

[MappingException: Association references unmapped class: System.String]

NHibernate.Cfg.XmlHbmBinding.CollectionBinder.BindCollectionSecondPass(ICollectionPropertiesMapping collectionMapping, Collection model, IDictionary`2 persistentClasses, IDictionary`2 inheritedMetas) in c:\Users\sebros\Documents\My Projects\nhibernate-core\src\NHibernate\Cfg\XmlHbmBinding\CollectionBinder.cs:741
NHibernate.Cfg.XmlHbmBinding.<>c__DisplayClass13.<AddCollectionSecondPass>b__12(IDictionary`2 persistentClasses) in c:\Users\sebros\Documents\My Projects\nhibernate-core\src\NHibernate\Cfg\XmlHbmBinding\CollectionBinder.cs:448
NHibernate.Cfg.Configuration.SecondPassCompile() in c:\Users\sebros\Documents\My Projects\nhibernate-core\src\NHibernate\Cfg\Configuration.cs:1106
NHibernate.Cfg.Configuration.BuildSessionFactory() in c:\Users\sebros\Documents\My Projects\nhibernate-core\src\NHibernate\Cfg\Configuration.cs:1261
Orchard.Data.SessionFactoryHolder.BuildSessionFactory() in c:\svn\trunk\src\Apps\Orchard\src\Orchard\Data\SessionFactoryHolder.cs:91
Orchard.Data.SessionFactoryHolder.GetSessionFactory() in c:\svn\trunk\src\Apps\Orchard\src\Orchard\Data\SessionFactoryHolder.cs:69
Orchard.Data.SessionLocator.EnsureSession() in c:\svn\trunk\src\Apps\Orchard\src\Orchard\Data\SessionLocator.cs:109
Orchard.Data.SessionLocator.Demand() in c:\svn\trunk\src\Apps\Orchard\src\Orchard\Data\SessionLocator.cs:40
Orchard.Data.SessionLocator.For(Type entityType) in c:\svn\trunk\src\Apps\Orchard\src\Orchard\Data\SessionLocator.cs:34
Orchard.ContentManagement.DefaultContentManager.GetManyImplementation(QueryHints hints, Action`2 predicate) in c:\svn\trunk\src\Apps\Orchard\src\Orchard\ContentManagement\DefaultContentManager.cs:326
Orchard.ContentManagement.DefaultContentManager.Get(Int32 id, VersionOptions options, QueryHints hints) in c:\svn\trunk\src\Apps\Orchard\src\Orchard\ContentManagement\DefaultContentManager.cs:160
Orchard.ContentManagement.DefaultContentManager.Get(Int32 id, VersionOptions options) in c:\svn\trunk\src\Apps\Orchard\src\Orchard\ContentManagement\DefaultContentManager.cs:131
Orchard.ContentManagement.DefaultContentManager.Get(Int32 id) in c:\svn\trunk\src\Apps\Orchard\src\Orchard\ContentManagement\DefaultContentManager.cs:127
Orchard.Security.Providers.FormsAuthenticationService.GetAuthenticatedUser() in c:\svn\trunk\src\Apps\Orchard\src\Orchard\Security\Providers\FormsAuthenticationService.cs:110
Orchard.Security.CurrentUserWorkContext.<Get>b__0(WorkContext ctx) in c:\svn\trunk\src\Apps\Orchard\src\Orchard\Security\CurrentUserWorkContext.cs:13
Orchard.Environment.<>c__DisplayClass7`1.<FindResolverForState>b__5() in c:\svn\trunk\src\Apps\Orchard\src\Orchard\Environment\WorkContextImplementation.cs:37
Orchard.Environment.WorkContextImplementation.GetState(String name) in c:\svn\trunk\src\Apps\Orchard\src\Orchard\Environment\WorkContextImplementation.cs:28
Orchard.WorkContext.get_CurrentUser() in c:\svn\trunk\src\Apps\Orchard\src\Orchard\WorkContext.cs:60
Orchard.Security.Authorizer.Authorize(Permission permission, IContent content, LocalizedString message) in c:\svn\trunk\src\Apps\Orchard\src\Orchard\Security\Authorizer.cs:72
Orchard.Security.Authorizer.Authorize(Permission permission) in c:\svn\trunk\src\Apps\Orchard\src\Orchard\Security\Authorizer.cs:60
Orchard.Exceptions.DefaultExceptionPolicy.RaiseNotification(Exception exception) in c:\svn\trunk\src\Apps\Orchard\src\Orchard\Exceptions\DefaultExceptionPolicy.cs:69
Orchard.Exceptions.DefaultExceptionPolicy.HandleException(Object sender, Exception exception) in c:\svn\trunk\src\Apps\Orchard\src\Orchard\Exceptions\DefaultExceptionPolicy.cs:44
Orchard.Events.DefaultOrchardEventBus.TryNotifyHandler(IEventHandler eventHandler, String messageName, String interfaceName, String methodName, IDictionary`2 eventData, IEnumerable& returnValue) in c:\svn\trunk\src\Apps\Orchard\src\Orchard\Events\DefaultOrchardEventBus.cs:56
Orchard.Events.<NotifyHandlers>d__0.MoveNext() in c:\svn\trunk\src\Apps\Orchard\src\Orchard\Events\DefaultOrchardEventBus.cs:41
System.Linq.Buffer`1..ctor(IEnumerable`1 source) +520
System.Linq.Enumerable.ToArray(IEnumerable`1 source) +103
Orchard.Events.DefaultOrchardEventBus.Notify(String messageName, IDictionary`2 eventData) in c:\svn\trunk\src\Apps\Orchard\src\Orchard\Events\DefaultOrchardEventBus.cs:27
Orchard.Environment.State.DefaultProcessingEngine.Execute(Entry entry) in c:\svn\trunk\src\Apps\Orchard\src\Orchard\Environment\State\DefaultProcessingEngine.cs:101
Orchard.Environment.State.DefaultProcessingEngine.ExecuteNextTask() in c:\svn\trunk\src\Apps\Orchard\src\Orchard\Environment\State\DefaultProcessingEngine.cs:67
Orchard.Environment.DefaultOrchardHost.EndRequest() in c:\svn\trunk\src\Apps\Orchard\src\Orchard\Environment\DefaultOrchardHost.cs:230
Orchard.Environment.DefaultOrchardHost.Orchard.Environment.IOrchardHost.EndRequest() in c:\svn\trunk\src\Apps\Orchard\src\Orchard\Environment\DefaultOrchardHost.cs:82
Orchard.Web.MvcApplication.HostEndRequest(HttpApplication application, IOrchardHost host) in c:\svn\trunk\src\Apps\Orchard\src\Orchard.Web\Global.asax.cs:42
Orchard.WarmupStarter.Starter`1.OnEndRequest(HttpApplication application) in c:\svn\trunk\src\Apps\Orchard\src\Orchard.WarmupStarter\Starter.cs:75
Orchard.Web.MvcApplication.Application_EndRequest() in c:\svn\trunk\src\Apps\Orchard\src\Orchard.Web\Global.asax.cs:33

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

System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor) +0
System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments) +229
System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture) +193
System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters) +35
System.Web.Util.ArglessEventHandlerProxy.Callback(Object sender, EventArgs e) +74
System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +80
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +165


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

This error occured as soon as my module was enabled. Since it is an NHibernate exception I assumed it was caused either by a ContentPartRecord or by Migrations.cs. But I hadn’t changed anything in there. After searching for a root cause for a while (again, the exception didn’t help much in finding where the cause of the error could be found), I saw that I had created a class in the Models folder which had a property called Id. This class was neither ContentPartRecord nor referenced in Migrations.cs but I wondered whether the fact that Id is the default Identifier Property Name and it was indeed a string, maybe this was causing the problem. So I just renamed the property to something else and it solved my problem !

I am not too sure whether I only had this exception because the class was defined in the Models folder or whether it could have happened in any other folder. But I’m just not in the mood to try moving the class and renaming the property back to Id.

Leave a Reply

Your email address will not be published.