More in this section

Forums / General Discussions / Tring to follow the tutorial.... get error

Tring to follow the tutorial.... get error

7 posts, 0 answered
  1. Paolo
    Paolo avatar
    147 posts
    Registered:
    11 Jun 2009
    06 May 2011
    Link to this post
    Hello,
    I'm tring to follow the custom module tutorial on the "Sitefinity 4 Developer Guide", the paragraph "How to create a custom content-based module" ... I've followed everything but I got an error and a question ...
    the error is

    No metadata has been registered for class xxxx. (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:/Projects/SF/bin/xxx.DLL.)

    [OpenAccessException: No metadata has been registered for class xxx. (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:/Projects/xxx/bin/xxx.DLL.)] DynamicModule.ns.Wrapped_OpenAccessRoleProvider_3b52f69fef634a64987d97223a1222ab.GetRolesForUser(Guid userId) +295 Telerik.Sitefinity.Security.SitefinityPrincipal.Initialize() +1036 Telerik.Sitefinity.Security.SitefinityPrincipal.get_Roles() +9 Telerik.Sitefinity.Configuration.RolePolicyHandler.GetPolicyNames(ConfigProvider configProvider, ConfigSection section) +46 Telerik.Sitefinity.Configuration.ConfigElement.GetValueFromPolicy(ConfigPolicyHandler handler, ConfigProperty prop, Object& value) +101 Telerik.Sitefinity.Configuration.ConfigElement.GetPolicyValue(ConfigProperty prop, Object& value) +87 Telerik.Sitefinity.Configuration.ConfigElement.get_Item(ConfigProperty prop) +56 Telerik.Sitefinity.Services.SystemConfig.get_CacheDependencyHandlers() +68 Telerik.Sitefinity.Data.CacheDependency..cctor() +79 [TypeInitializationException: The type initializer for 'Telerik.Sitefinity.Data.CacheDependency' threw an exception.] Telerik.Sitefinity.Data.CacheDependency.Subscribe(Type handlerType, Object trackedItem, ChangedCallback callback) +0 Telerik.Sitefinity.Configuration.ConfigCacheDependency.Initialize(CacheItem owningCacheItem) +74 Telerik.Microsoft.Practices.EnterpriseLibrary.Caching.CacheItem.InitializeExpirations() +30 Telerik.Microsoft.Practices.EnterpriseLibrary.Caching.Cache.Add(String key, Object value, CacheItemPriority scavengingPriority, ICacheItemRefreshAction refreshAction, ICacheItemExpiration[] expirations) +508 Telerik.Microsoft.Practices.EnterpriseLibrary.Caching.CacheManager.Add(String key, Object value, CacheItemPriority scavengingPriority, ICacheItemRefreshAction refreshAction, ICacheItemExpiration[] expirations) +28 Telerik.Sitefinity.Configuration.ConfigSection.HasPolicy(ConfigPolicyHandler policyHandler, String policyName, PolicyStatusInfo& policyStatus) +186 Telerik.Sitefinity.Configuration.ConfigElement.GetValueFromPolicy(ConfigPolicyHandler handler, ConfigProperty prop, Object& value) +182 Telerik.Sitefinity.Configuration.ConfigElement.GetPolicyValue(ConfigProperty prop, Object& value) +87 Telerik.Sitefinity.Configuration.ConfigElement.get_Item(ConfigProperty prop) +56 Telerik.Sitefinity.Configuration.ConfigElement.get_Item(String propertyName) +68 Telerik.Sitefinity.Security.Configuration.SecurityConfig.get_ApplicationRoles() +17 Telerik.Sitefinity.Security.SitefinityPrincipal.get_IsBackendUser() +56 Telerik.Sitefinity.Security.SecurityManager.AuthenticateRequest(HttpContextBase context) +903 Telerik.Sitefinity.Web.SitefinityHttpModule.Context_AuthenticateRequest(Object sender, EventArgs e) +18 System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +148 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +75

    What I've not found in the documentation is where the class is mapped to? I think I've to specify somewhere the type of my item and I think that I should place it in the App.Config reading from :

    <ProjectExtensions>
      <VisualStudio>
        <UserProperties OpenAccess_EnhancementOutputLevel="1" OpenAccess_UpdateDatabase="False" OpenAccess_Enhancing="False" OpenAccess_ConnectionId="DatabaseConnection1" OpenAccess_ConfigFile="App.config" />
      </VisualStudio>
    </ProjectExtensions>
    <PropertyGroup>
      <OpenAccessPath>$(SolutionDir)\..\..\..\..\..\Common\Dependencies</OpenAccessPath>
    </PropertyGroup>
    <Import Condition="Exists('$(OpenAccessPath)\OpenAccess.targets')" Project="$(OpenAccessPath)\OpenAccess.targets" />

    Thanks
    Paolo
  2. SelAromDotNet
    SelAromDotNet avatar
    912 posts
    Registered:
    18 Jul 2012
    06 May 2011
    Link to this post
    the following line:

    <Import Condition="Exists('$(OpenAccessPath)\OpenAccess.targets')" Project="$(OpenAccessPath)\OpenAccess.targets" />

    should be added to your project file (eg "myproject.csproj") not the app.config file. This configures the project to be enhanced for openaccess, which along with the fluent mappings handles mapping your type to the database.

    You have to right-click the project in the solution and select "Unload" to edit the csproj file in visual studio, or you can simply open it from the file explorer using a text editor like notepad.

    I hope this was helpful! Let me know if adding this to the project file doesn't resolve your issue.
  3. Paolo
    Paolo avatar
    147 posts
    Registered:
    11 Jun 2009
    06 May 2011
    Link to this post
    Hello,
    I wrongly reported in the thread... I've added to the csproj.... but in the App.Config should I define what the mapping is?
    Thanks

    Paolo
  4. SelAromDotNet
    SelAromDotNet avatar
    912 posts
    Registered:
    18 Jul 2012
    06 May 2011
    Link to this post
    if you are using Sitefinity 4.1 or later, the mappings are now handled using the new OpenAccess fluent mapper and are no longer defined in web.config. This is explained in this section:

    http://www.sitefinity.com/40/help/developers-guide/how-to-how-to-create-a-custom-content-based-module-implementing-the-provider-pattern-creating-the-fluent-mappings.html

    Fluent mappings replace the old app.config way of mapping classes to the database. Here is video series I found very helpful in making sense of this new concept

    http://tv.telerik.com/series/getting-started-with-fluent-mapping-for-openaccess-orm

    I find the fluent mapping to be a big improvement in developing data-persistent objects, so if you're not yet on 4.1 I encourage you to upgrade so you can take advantage of it and not worry about the app.config anymore :)

    hope this was helpful!
  5. Paolo
    Paolo avatar
    147 posts
    Registered:
    11 Jun 2009
    09 May 2011
    Link to this post
    Hello,
    yes I'm using 4.1 ... but I've to create the table in the DB?
    Thanks
  6. SelAromDotNet
    SelAromDotNet avatar
    912 posts
    Registered:
    18 Jul 2012
    09 May 2011
    Link to this post
    the fluent mapping automatically handles creating the database and mapping it to your object when the module is initialized. you shouldn't have to access the database at all. that's the benefit of using openaccess :)
  7. Paolo
    Paolo avatar
    147 posts
    Registered:
    11 Jun 2009
    09 May 2011
    Link to this post
    Ok, I should be ok with the openaccess... now I got another problem regarding the custom template....

    I've defined this :

    namespace SitefinityWebApp
    {
        public class Global : System.Web.HttpApplication
        {
      
            protected void Application_Start(object sender, EventArgs e)
            {
                Telerik.Sitefinity.Abstractions.Bootstrapper.Initializing += new EventHandler<Telerik.Sitefinity.Data.ExecutingEventArgs>(Bootstrapper_Initializing);
            }
      
            protected void Bootstrapper_Initializing(object sender, Telerik.Sitefinity.Data.ExecutingEventArgs args)
            {
                if (args.CommandName == "RegisterRoutes")
                {
                    var virtualPathConfig = Config.Get<VirtualPathSettingsConfig>();
                    var jobsModuleVirtualPathConfig = new VirtualPathElement(virtualPathConfig.VirtualPaths)
                    {
                        VirtualPath = "~/UC/*",
                        ResolverName = "EmbeddedResourceResolver",
                        ResourceLocation = "SitefinityWebApp"
                    };
                    virtualPathConfig.VirtualPaths.Add(jobsModuleVirtualPathConfig);
                }
            }

    Where SiteFinityWebApp is my application's namespace...
    when I try to load the page I get a message that ~/UC/SitefinityWebApp.Resources.Views.myuc.ascx";

    cannot be loaded... I've set embedded resource ... I've set nowhere the Views namespace... should I place it in the custom tool namespace under properties??

    Thanks

7 posts, 0 answered