Problems getting custom module to work

Posted by Community Admin on 04-Aug-2018 23:13

Problems getting custom module to work

All Replies

Posted by Community Admin on 12-May-2011 00:00

I followed to a T the online developers guide for creating custom modules, found here www.sitefinity.com/.../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

 

Posted by Community Admin on 13-May-2011 00:00

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

Posted by Community Admin on 13-May-2011 00:00

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);
        
    

Posted by Community Admin on 16-May-2011 00:00

Chirs,

Please let me know if you got to any solution. I have the same issue with Products module: www.sitefinity.com/.../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.

Posted by Community Admin on 16-May-2011 00:00

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.

Posted by Community Admin on 18-May-2011 00:00

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

Posted by Community Admin on 18-May-2011 00:00

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

Posted by Community Admin on 18-May-2011 00:00

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

Posted by Community Admin on 19-May-2011 00:00

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

Posted by Community Admin on 19-May-2011 00:00

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.

Posted by Community Admin on 20-May-2011 00:00

@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

Posted by Community Admin on 24-May-2011 00:00

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

This thread is closed