1-888-365-2779
+1-888-365-2779
Try Now
More in this section

Forums / Developing with Sitefinity / Problems getting custom module to work

Problems getting custom module to work

12 posts, 0 answered
  1. Chris Rigdon
    Chris Rigdon avatar
    4 posts
    Registered:
    19 Feb 2010
    12 May 2011
    Link to this post
    I followed to a T the online developers guide for creating custom modules, found here http://www.sitefinity.com/40/help/developers-guide/how-to-how-to-create-a-custom-content-based-module.html, but after registering my module, now I get the following error when I try to start my project.  Any help would be appreciated.

    No metadata has been registered for class RecipeModule.Model.Recipe. (This usually indicates, that either this class is not declared persistent or it is declared persistent but not enhanced. The class was loaded from file:///C:/svn/web/bin/RecipeModule.DLL.)

    Stack Trace:


    [OpenAccessException: No metadata has been registered for class RecipeModule.Model.Recipe. (This usually indicates, that either this class is not declared persistent or it is declared persistent but not enhanced. The class was loaded from file:///C:/Barkley-svn/Ball/web/bin/RecipeModule.DLL.)]
       DynamicModule.ns.Wrapped_OpenAccessUserActivityProvider_4f330f45e8574a25bff74e5ae2adabaf.Initialize(String providerName, NameValueCollection config, Type managerType) +281
       Telerik.Sitefinity.Data.ManagerBase`1.InstantiateProvider(IDataProviderSettings providerSettings, Type providerType, ExceptionPolicyName policy, ManagerBase`1 manager) +2706
       Telerik.Sitefinity.Data.ManagerBase`1.InstantiateProvider(IDataProviderSettings providerSettings, ExceptionPolicyName policy, ManagerBase`1 manager) +117
       Telerik.Sitefinity.Data.ManagerBase`1.SetProvider(String providerName, String transactionName) +407
       Telerik.Sitefinity.Data.ManagerBase`1..ctor(String providerName, String transactionName) +249
       Telerik.Sitefinity.Data.ManagerBase`1..ctor() +37
       Telerik.Sitefinity.Security.UserActivityManager..ctor() +28

    [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() +103
       Telerik.Sitefinity.Data.ManagerBase`1.GetManager(String providerName, String transactionName) +123
       Telerik.Sitefinity.Data.ManagerBase`1.GetManager() +72
       Telerik.Sitefinity.Security.UserActivityManager.GetManager() +27
       Telerik.Sitefinity.Security.SecurityManager.AuthenticateRequest(HttpContextBase context) +1614
       Telerik.Sitefinity.Web.SitefinityHttpModule.Context_AuthenticateRequest(Object sender, EventArgs e) +53
       System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +148
       System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +75

     
  2. Ivan Dimitrov
    Ivan Dimitrov avatar
    16072 posts
    Registered:
    12 Sep 2017
    13 May 2011
    Link to this post
    Hello Chris,

    It looks like the module has not been enhanced. The error you get indicated that you have a class that is not mapped in the OpenAccess metadata. There can be various reasons for this. If you have an Open Access provider that is used to manipulate this persistent type it should declare the assembly where this persistent class is located, this happens in the GetPersistentAssemblies method of the provider. Also is the class marked as persistent with the Persistent attribute?

    All the best,
    Ivan Dimitrov
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  3. Chris Rigdon
    Chris Rigdon avatar
    4 posts
    Registered:
    19 Feb 2010
    13 May 2011
    Link to this post
    Thank you Ivan for the response.  I have made the changes you outlined and I still have the same issue.  Here is my model class.  You can see that I have it marked with the persistent attribute.  I follow the Products module example in the SDK to implement the GetPersistentAssemblies method.  I included that code below as well.  Any other ideas of what I am missing?

    using Telerik.OpenAccess;
    using Telerik.Sitefinity;
    using Telerik.Sitefinity.GenericContent.Model;
     
    namespace RecipeModule.Model
    {
        [ManagerType("RecipeModule.RecipesManager, Recipes")]
        [Persistent(IdentityField = "contentId")]
        public class Recipe : Content
        {
            private string name;
            private string difficulty;
            private string mainIngredient;
     
            public override bool SupportsContentLifecycle
            {
                get { return false; }
            }
     
            [FieldAlias("name")]
            public string Name
            {
                get { return this.name; }
                set { this.name = value; }
            }
     
            [FieldAlias("mainIngredient")]
            public string MainIngredient
            {
                get { return this.mainIngredient; }
                set { this.mainIngredient = value; }
            }
     
            [FieldAlias("difficulty")]
            public string Difficulty
            {
                get { return this.difficulty; }
                set { this.difficulty = value; }
            }
        }
    }


    using System;
    using System.Linq;
    using System.Reflection;
    using RecipeModule.Model;
    using Telerik.OpenAccess;
    using Telerik.Sitefinity.Data;
    using Telerik.Sitefinity.Data.Linq;
    using Telerik.Sitefinity.Model;
    using Telerik.Sitefinity.Modules.GenericContent.Data;
    using Telerik.Sitefinity.Security;
    using Telerik.OpenAccess.Metadata;
     
    namespace RecipeModule.Data.Implementation
    {
        [ContentProviderDecorator(typeof(OpenAccessContentDecorator))]
        public class OpenAccessRecipeDataProvider : RecipesDataProviderBase, IOpenAccessDataProvider
        {
            private static Assembly[] peristentAssemblies;
     
            static OpenAccessRecipeDataProvider()
            {
                peristentAssemblies = new Assembly[] { typeof(Recipe).Assembly };
            }
     
     
            public Database Database
            {
                get;
                set;
            }
     
            public bool UseImplicitTransactions
            {
                get { return true; }
            }
     
            public TransactionMode TransactionConcurrency
            {
                get
                {
                    return TransactionMode.PESSIMISTIC_EXPLICIT;
                }
            }
     
            public Assembly[] GetPersistentAssemblies()
            {
                return peristentAssemblies;
            }
     
            public override Recipe CreateRecipe()
            {
                return this.CreateRecipe(Guid.NewGuid());
            }
     
            public override Recipe CreateRecipe(Guid id)
            {
                var dateValue = DateTime.UtcNow;
     
                var item = new Recipe()
                {
                    Id = id,
                    ApplicationName = this.ApplicationName,
                    Owner = SecurityManager.GetCurrentUserId(),
                    DateCreated = dateValue,
                    PublicationDate = dateValue
                };
     
                ((IDataItem)item).Provider = this;
     
                if (id != Guid.Empty)
                {
                    this.GetContext().Add(item);
                }
     
                return item;
            }
     
            public override IQueryable<Recipe> GetRecipes()
            {
                var appName = this.ApplicationName;
     
                var query =
                    SitefinityQuery
                    .Get<Recipe>(this, MethodBase.GetCurrentMethod())
                    .Where(b => b.ApplicationName == appName);
     
                return query;
            }
     
            public override Recipe GetRecipe(Guid id)
            {
                if (id == Guid.Empty)
                    throw new ArgumentNullException("id");
     
                var item = this.GetContext().GetItemById<Recipe>(id.ToString());
                ((IDataItem)item).Provider = this;
                return item;
            }
     
            public override void DeleteRecipe(Recipe application)
            {
                var context = this.GetContext();
                if (context != null)
                {
                    context.Remove(application);
                }
            }
     
            public OpenAccessProviderContext Context
            {
                get;
                set;
            }
     
            public MetadataSource GetMetaDataSource(IDatabaseMappingContext context)
            {
                return new RecipesFluentMetadataSource(context);
            }
        }
    }
  4. FlR
    FlR avatar
    49 posts
    Registered:
    05 Oct 2010
    16 May 2011
    Link to this post
    Chirs,

    Please let me know if you got to any solution. I have the same issue with Products module: http://www.sitefinity.com/devnet/forums/sitefinity-4-x/developing-with-sitefinity/installing-products-module.aspx

    I really miss the happiness working with SF3.7 modules - everything was working.

    On SF4.1 it takes me 1 day to install a sample module and make it working.
  5. Chris Rigdon
    Chris Rigdon avatar
    4 posts
    Registered:
    19 Feb 2010
    16 May 2011
    Link to this post
    No.  I still haven't found a solution.  I was hoping to hear back from a the Telerik team, they are normally pretty good at helping you find a solution.

    If I find the solution, I will be sure to post it here.
  6. Anton Mernov
    Anton Mernov avatar
    110 posts
    Registered:
    03 Dec 2008
    18 May 2011
    Link to this post
    Hi Guys,

    I have the same issue with my custom module after upgrading from SF 4.1 to SF 4.1 SP1.

    Did you get the following error from OA enhancer in the output window?
    MSBUILD : OpenAccess Enhancer warning : No persistent classes found. Is the metadata information missing?

    Best regards,
    Anton
  7. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    18 May 2011
    Link to this post
    Hello Anton Mernov,

    Can you please show us a piece of your custom module? We need to see how you are declaring your persistent fields and how you perform the fluent mapping.

    All the best,
    Radoslav Georgiev
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  8. Anton Mernov
    Anton Mernov avatar
    110 posts
    Registered:
    03 Dec 2008
    18 May 2011
    Link to this post
    My custom class is not based on Content class.

    The VoiceItem class:
    [DataContract]
    [ManagerType("KT.VoiceManager, KT")]
    [Persistent(IdentityField = "Id")]
    public class VoiceItem
    {
        [DataMember]
        public Guid Id { get; set; }
     
        [DataMember]
        public DateTime DateCreated { get; set; }
     
        [DataMember]
        public Guid OwnerId { get; set; }
     
        [DataMember]
        public Guid ForUserId { get; set; }
     }

    The fluent mapping:
    MappingConfiguration<VoiceItem> voiceConfiguration = new MappingConfiguration<VoiceItem>();
    voiceConfiguration.HasProperty(v => v.Id).IsIdentity();
    voiceConfiguration.HasProperty(v => v.DateCreated);
    voiceConfiguration.HasProperty(v => v.OwnerId);
    voiceConfiguration.HasProperty(v => v.ForUserId);
    voiceConfiguration.MapType(v => new { }).ToTable("kt_voices");

    Thanks in advance,
    Anton
  9. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    19 May 2011
    Link to this post
    Hi Anton Mernov,

    The fluent mapping of OA automatically maps fields. From your class I can see that you have auto implemented properties rather than having properties backed by fields. Using your current approach of mapping your properties should be backed by fields having the same names using camelCase naming convention. For example:
    [DataMember]
    public DateTime DateCreated
    {
        get
        {
            return this.dateCreated;
        }
        set
        {
            this.dateCreated = value.ToUniversalTime();
        }
    }
     
    private DateTime dateCreated;


    Regards,
    Radoslav Georgiev
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  10. Anton Mernov
    Anton Mernov avatar
    110 posts
    Registered:
    03 Dec 2008
    19 May 2011
    Link to this post
    Hi Radoslav,

    I've updated my class as you mentioned but I still getting the same warning:
    MSBUILD : OpenAccess Enhancer warning : No persistent classes found. Is the metadata information missing?
     
    Any other ideas?

    Best regards,
    Anton.
  11. Anton Mernov
    Anton Mernov avatar
    110 posts
    Registered:
    03 Dec 2008
    20 May 2011
    Link to this post
    @everyone

    It seems, something  was changed in OpenAccess dlls and OA enhancer from SDK for SF 4.1 no longer works for SF 4.1 SP1. I just downloaded the SDK for SF 4.1 SP1 from my account and installed it.

    Now I am able to compile and install my custom module without any errors. I hope this helps.

    Best regards,
    Anton
  12. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    24 May 2011
    Link to this post
    Hello,

    The OpenAccess version in Sitefinity 4.1 SP1 has been upgraded. This is why you need to use the 4.1 SP1 SDK to enhance your assemblies.

    All the best,
    Radoslav Georgiev
    the Telerik team
    Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
12 posts, 0 answered