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

Forums / Developing with Sitefinity / Nolics: Inheriting from

Nolics: Inheriting from

16 posts, 0 answered
  1. Andy
    Andy avatar
    62 posts
    Registered:
    01 Aug 2008
    05 Jun 2009
    Link to this post

    I wanted to extend the Telerik.DataAccess.AspnetProviders.User class (as below) in my own module.

    namespace EA.Sitefinity.Projects.Data 
     
        public class User : Telerik.DataAccess.AspnetProviders.User 
        { 
            public string FirstName 
            { 
                get { return (string)this.Profile.MetaData[0].Value; } 
                set { this.Profile.MetaData[0].Value = value; } 
            } 
     
            public string LastName 
            { 
                get { return (string)this.Profile.MetaData[1].Value; } 
                set { this.Profile.MetaData[1].Value  = value; } 
            } 
        } 

    I keep getting an error:
    "The database class EA.Sitefinity.Projects.Data.User has not been registered. Use DataConnection.Initialize or DataConnection.RegisterAssembly to register an assembly."

    I'm not sure where to do this. I attempted to register (as below) in the DefaultProvider.Initialise but I get the same error message on my new lines instead.

            public override void Initialize(string name, NameValueCollection config) 
            { 
                // upgrades the database with Nolics 
                if (string.IsNullOrEmpty(name)) 
                    name = "DefaultProjectsProvider"
                if (string.IsNullOrEmpty(config["description"])) 
                    config.Add("description", Messages.DefaultProviderDescription); 
     
                this.app = ApplicationHelper.GetApplication(config); 
     
                Assembly assembly = Assembly.GetExecutingAssembly(); 
     
                //DataConnection.RegisterAssembly(typeof(EA.Sitefinity.Projects.Data.User).Assembly);   << Fix attempt 1 
                //DataConnection.Initialize(false, typeof(EA.Sitefinity.Projects.Data.User).Assembly);   << Fix attempt 2 
     
                DataConnection.Initialize(false, assembly);  // << Get error on this line 
                this.odbProvider = NolicsHelper.SetConnection(config["connectionStringName"], name); 
                bool upgrade = false
                 
                this.odbProvider.Upgrade(); 
                base.Initialize(name, config); 
                            
            } 

    Where and how should I register the Telerik.DataAccess.AspnetProviders assembly?

    Thanks! Andy.

  2. Vlad
    Vlad avatar
    498 posts
    Registered:
    19 Jun 2017
    08 Jun 2009
    Link to this post
    Hi Andy,

    Everything seems fine for me in the provided implementation, and I am not sure what could be the problem.
    However, could you try to force initializing TelerikMembershipProvider before register your dbclass:
        public override void Initialize(string name, NameValueCollection config) 
        { 
            // upgrades the database with Nolics  
            if (string.IsNullOrEmpty(name)) 
                name = "DefaultProjectsProvider"
            if (string.IsNullOrEmpty(config["description"])) 
                config.Add("description", Messages.DefaultProviderDescription); 
     
            this.app = ApplicationHelper.GetApplication(config); 
     
            Assembly assembly = Assembly.GetExecutingAssembly(); 
     
            //DataConnection.RegisterAssembly(typeof(EA.Sitefinity.Projects.Data.User).Assembly);   << Fix attempt 1  
            //DataConnection.Initialize(false, typeof(EA.Sitefinity.Projects.Data.User).Assembly);   << Fix attempt 2  
     
            MembershipProviderCollection mProviders = Membership.Providers; 
     
            DataConnection.Initialize(false, assembly);  // << Get error on this line  
            this.odbProvider = NolicsHelper.SetConnection(config["connectionStringName"], name); 
            bool upgrade = false
     
            this.odbProvider.Upgrade(); 
            base.Initialize(name, config); 
     
        }  

    I hope this will resolve the issue. Do let me know if it does.

    Sincerely yours,
    Vlad
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  3. Andy
    Andy avatar
    62 posts
    Registered:
    01 Aug 2008
    09 Jun 2009
    Link to this post
    Hi Vlad, thanks for the reply.

    Unfortunately I'm still getting an error.

            public override void Initialize(string name, NameValueCollection config)             
            { 
                // upgrades the database with Nolics 
                if (string.IsNullOrEmpty(name)) 
                    name = "DefaultProjectsProvider"
                if (string.IsNullOrEmpty(config["description"])) 
                    config.Add("description", Messages.DefaultProviderDescription); 
     
                this.app = ApplicationHelper.GetApplication(config); 
     
                Assembly assembly = Assembly.GetExecutingAssembly(); 
     
                MembershipProviderCollection mProviders = Membership.Providers; 
                DataConnection.RegisterAssembly(typeof(Telerik.DataAccess.AspnetProviders.User).Assembly); 
                DataConnection.Initialize(falsetypeof(Telerik.DataAccess.AspnetProviders.User).Assembly); 
     
                DataConnection.Initialize(false, assembly);  // <-- Error on this line 
                this.odbProvider = NolicsHelper.SetConnection(config["connectionStringName"], name); 
                bool upgrade = false
                 
                this.odbProvider.Upgrade(); 
                base.Initialize(name, config); 
                 
                 
     
            } 


    The error is "The database class EA.Sitefinity.Projects.Data.User has not been registered. Use DataConnection.Initialize or DataConnection.RegisterAssembly to register an assembly."

    This happens immediately you log in. Ie, before the dashboard is displayed.

    It only happens when you try to use the new User class in another dbClass, as below.

    dbclass Project [TableName = "sf_projects_Project"]  
         
        primary key string Application [50], guid ID [AutoGenGUID = True]; 
            
        string Title[50];                     
        string Number[20]; 
        string Status[50]; 
        string Description[500];    
        date StartDate[Format="dd/mm/yyyy"]; 
        date EndDate[Format="dd/mm/yyyy"]; 
        int Cost[Nullable=True];  
             
        link Telerik.DataAccess.AspnetProviders.User User_lnk: guid UserId;   // <- Works fine, though you have to edit the actual class file created by Nolics to add the full namespace, or to add a Using. 
     
        link User User_lnk: guid UserId;   // <- Linking to the derived wrapper class causes the error. 
         


    I have done what I needed to do another way for the moment, but it's not a good OO way.
  4. Andy
    Andy avatar
    62 posts
    Registered:
    01 Aug 2008
    09 Jun 2009
    Link to this post
    Sorry, the code I posted was misleading. I have tried registering both assemblies, you just get the same error in different places.

         public override void Initialize(string name, NameValueCollection config)             
            { 
                // upgrades the database with Nolics 
                if (string.IsNullOrEmpty(name)) 
                    name = "DefaultProjectsProvider"
                if (string.IsNullOrEmpty(config["description"])) 
                    config.Add("description", Messages.DefaultProviderDescription); 
     
                this.app = ApplicationHelper.GetApplication(config); 
     
                Assembly assembly = Assembly.GetExecutingAssembly(); 
     
                MembershipProviderCollection mProviders = Membership.Providers; 
                DataConnection.RegisterAssembly(typeof(Telerik.DataAccess.AspnetProviders.User).Assembly); 
                DataConnection.Initialize(falsetypeof(Telerik.DataAccess.AspnetProviders.User).Assembly);   
     
                DataConnection.RegisterAssembly(typeof(EA.Sitefinity.Projects.Data.User).Assembly);  // <-- In this case you get the error here 
                DataConnection.Initialize(falsetypeof(EA.Sitefinity.Projects.Data.User).Assembly); 
                             
                DataConnection.Initialize(false, assembly); 
                this.odbProvider = NolicsHelper.SetConnection(config["connectionStringName"], name); 
                bool upgrade = false
                 
                this.odbProvider.Upgrade(); 
                base.Initialize(name, config); 
                 
                 
     
            } 

    ... Which is odd, as it's complaining that the assembly you are trying to register is not registered!



  5. Vlad
    Vlad avatar
    498 posts
    Registered:
    19 Jun 2017
    09 Jun 2009
    Link to this post
    Hello Andy,

    Could you try to change the name of your class User (EA.Sitefinity.Projects.Data.User), i.e. EA.Sitefinity.Projects.Data.ProjectUser ?
    Maybe, it is conflicting with the existing Telerik.DataAccess.AspnetProviders.User.

    Best wishes,
    Vlad
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  6. Andy
    Andy avatar
    62 posts
    Registered:
    01 Aug 2008
    09 Jun 2009
    Link to this post
    Yeah, Vlad, I already tried that. Still the same! Sorry!

  7. Vlad
    Vlad avatar
    498 posts
    Registered:
    19 Jun 2017
    11 Jun 2009
    Link to this post
    Hello Andy,

    Unfortunately, we have no idea what else to suggest you.
    If you send us the full implementation of your module, we could investigate it locally and hopefully could be able to provide a solution. You can attach the source code in a new support ticket.

    Regards,
    Vlad
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  8. Andy
    Andy avatar
    62 posts
    Registered:
    01 Aug 2008
    12 Jun 2009
    Link to this post
    OK. Thanks for the help and I may go that path in the future, but I just need to get things working for the moment, so I'm coding a workaround.

    Here's an interesting thing though... I was previously developing in VS2005, but have not got licence for and installed VS2008, and moved the code to that.

    I'm now getting an error:

    {"GenericArguments[0], 'Telerik.DataAccess.AspnetProviders.User', on 'Nolics.ORMapper.Base.LinkToValue`1[P]' violates the constraint of type parameter 'P'.":""}

    on the line:

    DataConnection.Initialize(false, assembly);

    in the Provider.Initialize.

    I don't know if that gives additional clues? I have to leave it now for the weekend but will pick it up again on Monday....

    Have a good weekend!
    Andy

  9. Georgi
    Georgi avatar
    3583 posts
    Registered:
    28 Oct 2016
    16 Jun 2009
    Link to this post
    Hello Andy,

    Nolics is known with its poor support in Visual Studio 2008, I wonder if the error has anything to do with it. Our suggestion for sending us your implementation is still valid though.

    Regards,
    Georgi
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  10. Andy
    Andy avatar
    62 posts
    Registered:
    01 Aug 2008
    16 Jun 2009
    Link to this post
    Hi Georgi,

    As you say, Nolics in VS2008 wasn't working well, so I reverted back to VS2005, and I still get the same error. So I'm not sure what happened in moving it to 2008.

    I'll probably still go with my workaround solution (extending my Project-User link class with extra User properties/methods rather than inheriting from and wrapping the User class.)

    I've downloaded 3.6 SP2, so I'll probably re-build the module from scratch again rather than try to chase this down.

    I'm using Nolics version 4.2.2525.4, but is there a later version that's considered stable enough to use?

    Thanks! Andy
  11. Georgi
    Georgi avatar
    3583 posts
    Registered:
    28 Oct 2016
    16 Jun 2009
    Link to this post
    Hi Andy,

    Unfortunately this is the latest version. You might check the release notes at http://www.nolics.net/Download.aspx

    I wish you good luck with the new approach. Let us know if we could do anything to help.

    Sincerely yours,
    Georgi
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  12. Andy
    Andy avatar
    62 posts
    Registered:
    01 Aug 2008
    19 Jun 2009
    Link to this post
    Just as an addition to this thread, it seems that the rest of sitefinity is built with Nolics Engine v4.2.2522.4

    I don't know what the differences are between the two, but is there a reason why Sitefinity isn't built with 4.2.2525.4...?
  13. Georgi
    Georgi avatar
    3583 posts
    Registered:
    28 Oct 2016
    19 Jun 2009
    Link to this post
    Hi Andy,

    We tried to upgrade to the latest version of Nolics but met some problems. Instead of finding solutions, we decided to go with the version we know.

    Sincerely yours,
    Georgi
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  14. Andy
    Andy avatar
    62 posts
    Registered:
    01 Aug 2008
    19 Jun 2009
    Link to this post
    That's interesting.... the VS2005 plugin for the latest version is not working too great for me either. I don't know if it is me, or the code that Nolics is generating from the .dbclass files. I have to fiddle with the code after it's generated to get it to compile properly. Which is not ideal!

    Was this similar to the trouble you were having?
  15. Vlad
    Vlad avatar
    498 posts
    Registered:
    19 Jun 2017
    24 Jun 2009
    Link to this post
    Hello Andy,

    We don't remember what were the exact problems for not upgrading to the build 2525, however they we re not related to the Visual Studio integration. The issues appered on runtime.
    Actually, I don't think, that the exact installed Nolics version makes sense for generating the persistanse classes, the logic behind is probably the same in the both versions. For instance, we have created db classes with the lates Nolics beta release  for Visual Studio 2008, and then compiled them with the version 2522, without any problems.
    However, your problem could be related to something, which we haven't run against yet.

    Please let us know how can we help you further.

    Greetings,
    Vlad
    the Telerik team

    Instantly find answers to your questions on the new Telerik Support Portal.
    Check out the tips for optimizing your support resource searches.
  16. Andy
    Andy avatar
    62 posts
    Registered:
    01 Aug 2008
    25 Jun 2009
    Link to this post
    Thanks for the extra Info Vlad,

    I hope it will be easier to work with when OpenAccess is worked into the innards of Sitefinity in v4.0!

    Cheers guys!
Register for webinar
16 posts, 0 answered