This is a migrated thread and some comments may be shown as answers.

Type is enhanced and registered

11 Answers 377 Views
LINQ (LINQ specific questions)
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Garry
Top achievements
Rank 1
Garry asked on 24 Jun 2009, 06:15 PM
I have several Sitefinity modules that are using OpenAccess as their DAL and works wonderful, but for whatever reason I have one project that keeps throwing the following exception any time I try and do a query. I can't see any differences between my projects and can't seem to find the cause of this exception. Any ideas?

Edit** Jan, I upgraded my Sitefinity module projects to use the new OpenAccess version 2009.2.701.5 and I am getting the same error in my modules, but it looks to give more detail possibly. Here is that error.
Type is enhanced and registered, but not available from the database class meta data. This can be caused by a wrong connection id or configuration.  
Parameter name: src  
Actual value was GambitCreations.Sitefinity.ClaimsModule.Objects.ClaimsClaimType.   
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: System.ArgumentOutOfRangeException: Type is enhanced and registered, but not available from the database class meta data. This can be caused by a wrong connection id or configuration.  
Parameter name: src  
Actual value was GambitCreations.Sitefinity.ClaimsModule.Objects.ClaimsClaimType. 

Thanks!

System.ArgumentOutOfRangeException was unhandled by user code  
  Message="Type is enhanced and registered, but not available from the database class meta data. This can be caused by a wrong connection id or configuration.\r\nParameter name: src\r\nActual value was GambitCreations.Sitefinity.ReportModule.Objects.ReportsDataSource." 
  Source="Telerik.OpenAccess.Runtime" 
  ParamName="src" 
  StackTrace:  
       at Telerik.OpenAccess.RT.QueryBuilderImp..ctor(ObjectScope sc, Type src, Type trgt, String lang, Object exp)  
       at Telerik.OpenAccess.RT.ObjectScope.GetQueryBuilder(Type src, Type dest, String lang, Object exp)  
       at Telerik.OpenAccess.Query.QueryContext.GetQueryBuilder(Type type, Object exp)  
       at Telerik.OpenAccess.Query.QueryContext.PerformDatabaseQuery(Type type, Expression expression, Int32& number, Boolean exec, Int32 numSkip, Int32 numTake)  
       at Telerik.OpenAccess.Query.QueryContext.PerformDatabaseQueryMultiple[T](Expression expression)  
       at Telerik.OpenAccess.Query.ObjectScopeQuery`2.GetEnumerator()  
       at GambitCreations.Sitefinity.ReportModule.ReportManager.GetDataSourceListing() in C:\Users\GClark\Documents\Visual Studio 2008\Projects\KCDC\GambitCreations.Sitefinity.ReportModule\ReportsManager.cs:line 189  
       at GambitCreations.Sitefinity.ReportModule.WebControls.Admin.viewDataSourceListing`1.GridListing_NeedDataSource(Object source, GridNeedDataSourceEventArgs e) in C:\Users\GClark\Documents\Visual Studio 2008\Projects\KCDC\GambitCreations.Sitefinity.ReportModule\WebControls\Admin\viewDataSourceListing.cs:line 137  
       at Telerik.Web.UI.RadGrid.OnNeedDataSource(GridNeedDataSourceEventArgs e)  
       at Telerik.Web.UI.RadGrid.ObtainDataSource(GridRebindReason rebindReason, Boolean IsBoundUsingDataSourceId)  
       at Telerik.Web.UI.RadGrid.AutoDataBind(GridRebindReason rebindReason)  
       at Telerik.Web.UI.RadGrid.OnLoad(EventArgs e)  
       at System.Web.UI.Control.LoadRecursive()  
       at System.Web.UI.Control.LoadRecursive()  
       at System.Web.UI.Control.LoadRecursive()  
       at System.Web.UI.Control.LoadRecursive()  
       at System.Web.UI.Control.AddedControl(Control control, Int32 index)  
       at System.Web.UI.ControlCollection.Add(Control child)  
       at Telerik.Cms.Web.UI.ViewModeControl`1.CreateChildControls()  
       at System.Web.UI.Control.EnsureChildControls()  
       at System.Web.UI.Control.PreRenderRecursiveInternal()  
       at System.Web.UI.Control.PreRenderRecursiveInternal()  
       at System.Web.UI.Control.PreRenderRecursiveInternal()  
       at System.Web.UI.Control.PreRenderRecursiveInternal()  
       at System.Web.UI.Control.PreRenderRecursiveInternal()  
       at System.Web.UI.Control.PreRenderRecursiveInternal()  
       at System.Web.UI.Control.PreRenderRecursiveInternal()  
       at System.Web.UI.Control.PreRenderRecursiveInternal()  
       at System.Web.UI.Control.PreRenderRecursiveInternal()  
       at System.Web.UI.Control.PreRenderRecursiveInternal()  
       at System.Web.UI.Control.PreRenderRecursiveInternal()  
       at System.Web.UI.Control.PreRenderRecursiveInternal()  
       at System.Web.UI.Control.PreRenderRecursiveInternal()  
       at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)  
  InnerException:   
 

11 Answers, 1 is accepted

Sort by
0
Jan Blessenohl
Telerik team
answered on 30 Jun 2009, 05:23 PM
Hello Garry Clark,
It looks like there is a persistent type that belongs to a different database connection is used in your query.

Do you deal with 2 databases with different models?

Greetings,
Jan Blessenohl
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.
0
Garry
Top achievements
Rank 1
answered on 08 Jul 2009, 02:43 PM
Jan,
Sorry for the delay in responding, but a last minute gotcha on another project took me away for a bit. The module does not deal with 2 different databases with different models. Only DBs this deals with would be live and test DB which are mirrors of one another.

However I am suspecting the root of my problem is this code provided to me by Bob there at Telerik in another forum thread.

/// <summary>    
    /// Data access helper class.    
    /// </summary>    
    public static class DataAccess  
    {  
        public static Database GetDatabase()  
        {  
            if (database == null)  
            {  
                // Your connection string name.    
                var connenctionName = "Sitefinity";  
 
                database = Database.Get(connenctionName,  
                    GetConfiguration(connenctionName),  
                    new Assembly[] { typeof(DataAccess).Assembly });  
            }  
            return database;  
        }  
 
        public static XmlElement GetConfiguration(string connectionName)  
        {  
            // You can configure OpenAccess connections in web.config.    
            // In that case you have to have defined a connection with id = connectionName    
            var oaConfig = (XmlElement)ConfigurationManager.GetSection("openaccess");  
            if (oaConfig != null)  
                return oaConfig;  
 
            // OR you can parse standard ASP.NET connection strings.    
 
            string backend, databaseName, serverName, username, password;  
            var connString = ConfigurationManager.ConnectionStrings[connectionName];  
            var dbFactory = DbProviderFactories.GetFactory(connString.ProviderName);  
 
            if (dbFactory is SqlClientFactory)  
            {  
                // The OpenAccess Database configuration.    
                backend = "mssqlConfiguration";  
 
                var connBuilder = new SqlConnectionStringBuilder(connString.ConnectionString);  
 
                serverName = connBuilder.DataSource;  
                databaseName = connBuilder.InitialCatalog;  
                username = connBuilder.UserID;  
                password = connBuilder.Password;  
            }  
            else 
            {  
                // If you want to support other databases then MS SQL you could     
                // decide the correct OpenAccess configuration based on the client factory.    
                throw new NotSupportedException();  
            }  
 
            string connectionNode =  
                string.Format(  
                    @"<openaccess xmlns=""http://www.telerik.com/OpenAccess"">    
                    <connections>    
                      <connection id=""{0}"">    
                        <databasename>{1}</databasename>    
                        <servername>{2}</servername>    
                        <integratedSecurity>{3}</integratedSecurity>    
                        <user>{4}</user>    
                        <password>{5}</password>    
                        <backendconfigurationname>{6}</backendconfigurationname>    
                        <reference assemblyname=""{7}""/>    
                      </connection>    
                    </connections>  
                    </openaccess>",  
                    connectionName,  
                    databaseName,  
                    serverName,  
                    string.IsNullOrEmpty(username),  
                    username, password,  
                    backend,  
                    typeof(DataAccess).Assembly.FullName);  
 
            var doc = new XmlDocument();  
            doc.LoadXml(connectionNode);  
 
            return doc.DocumentElement;  
        }  
 
        private static Database database; 

I am applying this code in my ObjectScopeProvider class like this.
/// <summary>  
        /// Returns the instance of Database for the connectionId   
        /// specified in the Enable Project Wizard.  
        /// </summary>  
        /// <returns>Instance of Database.</returns>  
        /// <remarks></remarks>  
        static public Database Database()  
        {  
            if( theObjectScopeProvider1 == null )  
                theObjectScopeProvider1 = new ClaimsScopeProvider();  
 
            if (theObjectScopeProvider1.myDatabase == null)  
                theObjectScopeProvider1.myDatabase = DataAccess.GetDatabase(); //Telerik.OpenAccess.Database.Get( "Sitefinity" );  
 
            return theObjectScopeProvider1.myDatabase;  
        } 

Could this be my issue as I am now getting this same error in all of my Sitefinity modules that use OpenAccess after applying this code. Unfortunately even if I revert back to
/// <summary>  
        /// Returns the instance of Database for the connectionId   
        /// specified in the Enable Project Wizard.  
        /// </summary>  
        /// <returns>Instance of Database.</returns>  
        /// <remarks></remarks>  
        static public Database Database()  
        {  
            if( theObjectScopeProvider1 == null )  
                theObjectScopeProvider1 = new ClaimsScopeProvider();  
 
            if (theObjectScopeProvider1.myDatabase == null)  
                theObjectScopeProvider1.myDatabase = Telerik.OpenAccess.Database.Get( "Sitefinity" );  
 
            return theObjectScopeProvider1.myDatabase;  
        } 
 I get the same error now.

Any ideas or what do you need from me to figure this one out? As I am kind of dead in the water while this error lives.

Thanks!
0
Garry
Top achievements
Rank 1
answered on 08 Jul 2009, 07:35 PM
Jan,
Just wanted to let you know I did go ahead and open a ticket on this issue.

Ticket ID: 225750

Thank you for your help! 
0
Dhanvanth Rangabashyam
Top achievements
Rank 1
answered on 11 Aug 2009, 01:32 AM
I am facing a similar issue and in my case, I am dealing with two databases and two different schemas.

Is there anything that I need to do to avoid this error?
0
Garry
Top achievements
Rank 1
answered on 11 Aug 2009, 12:34 PM

Dhanvanth,
Below is the solution that worked for me. Let me know if this does not fix your issue.
Thanks!

Hi Garry,

It seems that the problem lies in OpenAccess not getting the correct connection settings. The exception says that wrong metadata information is loaded. I read in one of your previous posts that you have three modules. The problem with multiple modules lies in the connectionId name that you use when obtaining connection. You pass "Sitefinity" as a value for the connectionId, and that value is used in all of the three modules.
 When you obtain a Database connection, OpenAccess loads the metadata information for the persistent classes from the calling module. It then caches that connection, so after another module calls for a database connection, the same cached connection is returned. That way OpenAccess tries to use the metadata from the previous module to operate with the persistent classes from the new module.
The easiest way to solve this problem is to pass a unique connectionId for each module when you try to obtain a database connection with OpenAccess.


Best wishes,
Zoran
the Telerik team

0
PetarP
Telerik team
answered on 11 Aug 2009, 02:11 PM
Hi Dhanvanth Rangabashyam,

The solution provided by Garry Clark should be enough to solve your problem. Please do let us know if you face any further difficulties.

Best wishes,
Petar
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.
0
Dhanvanth Rangabashyam
Top achievements
Rank 1
answered on 11 Aug 2009, 06:26 PM
That worked perfectly. Thanks for the solution Gary.
0
Devanand Chahal
Top achievements
Rank 2
answered on 23 Oct 2009, 05:59 AM
I am facing the same problem, I have abt 14 packages (projects) in my application. Every project have its own scope provider and app.config. All the projects() working fine but in one project i am getting above said problem..... any idea plz....?


Regards,
Dev
0
Dimitar Kapitanov
Telerik team
answered on 23 Oct 2009, 06:05 AM
Hi Devanand Chahal,
Please check whether the connection id is unique or matches others  module connections settings id. The solution provided in this thread should work for you as well.

Greetings,
Dimitar Kapitanov
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Devanand Chahal
Top achievements
Rank 2
answered on 23 Oct 2009, 08:47 AM


Hello Dimitar,

I have 14 projects with app.config and scopeProvider for each project seprately in an application, I am using same connection id in all the app.config files for all projects. 13 projects which are having same connection id in their app.config file are working fine. but one project in the same solution is giving above said error.

As per your suggestion if we need unique connection id , then all my 14 projects in the same project should give me this error, but its working fine for all projects except one ....  can there be some other reason for the error???
0
PetarP
Telerik team
answered on 28 Oct 2009, 06:22 PM
Hello Devanand Chahal,

When you work in such scenarios, the reference to such assemblies must always be explicitly specified inside the <references> node of the <openAccess> section in your executing assembly.
The node has the following syntax:
<references>
    <reference assemblyname="MyAssembly" configrequired="True"/>
</references>
There should be a <reference> subnode for all of the assemblies that you are referencing and are containing persistent classes.

All the best,
Petar
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Tags
LINQ (LINQ specific questions)
Asked by
Garry
Top achievements
Rank 1
Answers by
Jan Blessenohl
Telerik team
Garry
Top achievements
Rank 1
Dhanvanth Rangabashyam
Top achievements
Rank 1
PetarP
Telerik team
Devanand Chahal
Top achievements
Rank 2
Dimitar Kapitanov
Telerik team
Share this question
or