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

RelationalKeyGeneratorFactory Problem

16 Answers 655 Views
Databases and Data Types
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Jouie
Top achievements
Rank 1
Jouie asked on 21 Jul 2009, 03:41 AM
Hi guys,

I got excited with the Q2 release of OpenAccess Express and did some uninstall of the old one and installation of the new one.

When testing it in my web apps, I got this error:

Unable to create RelationalKeyGeneratorFactory instance OpenAccessRuntime.Relational.sql.HighLowRelationalKeyGenerator+Factory

{"Unable to cast object of type 'Factory' to type 'OpenAccessRuntime.Relational.RelationalKeyGeneratorFactory'."}

in this code:

static public IObjectScope GetNewObjectScope()  
{  
   Database db = Database();  
 
   IObjectScope newScope = db.GetObjectScope();  // This is where it happens
   return newScope;  

But it works fine when running it in my console apps, same ObjectScope and models.

I even recreated all my tables, set the relationship using the Reverse Mapping tools...

By the way my db is MySql and most of my objects are relational.

Any solutions? Thanks in advance.

Cheers,
Jouie

16 Answers, 1 is accepted

Sort by
0
Jouie
Top achievements
Rank 1
answered on 21 Jul 2009, 06:44 AM
Hi guys,

Found the problem. When I deployed my application, I copied the related Telerik.OpenAccess libraries (old version) in the bin folder. So when I switch to the newer version, for some reason it's stil using that dlls eventhough I already removed it in the references.

Solution: Remove the Telerik.OpenAccess in the references. Deleted those files in the bin folder and add the new version again. And then that's it....works fine now.

Atleast you'll know what to do in case you encounter it also.

Cheers,

Jouie
0
Devanand Chahal
Top achievements
Rank 2
answered on 25 Sep 2009, 09:19 AM
I faced the same problem and did as Jouie  suggested , but  the error is still there ..... is there anything else to do in settings to avoid this problem.....


Dev
0
PetarP
Telerik team
answered on 26 Sep 2009, 03:12 PM
Hi Devanand Chahal,

Basically what Jouie  provided as a solution should work. One of the possible reasons for the behavior you are confronting is that you may have assemblies compiled with the old version of Telerik OpenAccess ORM. Can you please rebuild all your projects with the newest version of OpenAccess. Please be sure to double check that there are no old OpenAccess assemblies in the bin folder of your project. Also make sure that all the assemblies that have reference to OpenAccess like class libraries that contain persistent classes are also built with the same Telerik OpenAccess ORM version as the one that you refer in the bin.

This should solve the problem. In any other case please provide us with more details about the behavior you are getting. Are you having compilation errors or the exceptions are thrown during runtime? We are looking forward for your feedback,

Sincerely yours,
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.
0
Devanand Chahal
Top achievements
Rank 2
answered on 29 Sep 2009, 06:02 AM

Hello Petar:

I am getting error ar run time, when I am trying to execute method from Weborbconsole.html .

See the below error that i m getting. The same Error I was getting in 2008 version when I missed the entry of the table(that is/are mapped to any persistent class) in keygen table. after  entries for all the tables (Tables that are forward mapped to persistent classes) in to KEYGEN table, it works fine for 2008 version. after running it successfuly in 2008, I shift to 2009 version of telerik and got the error again. 


Telerik.OpenAccess.RT.sql.SQLException: Value was either too large or too small for an Int32. ---> System.OverflowException: Value was either too large or too small for an Int32.

   at System.Decimal.ToInt32(Decimal d)

   at Telerik.OpenAccess.RT.Adonet2Generic.Impl.ResultSetImp.getInt(Int32 columnIndex)

   --- End of inner exception stack trace ---

   at Telerik.OpenAccess.RT.Adonet2Generic.Impl.ResultSetImp.getInt(Int32 columnIndex)

   at OpenAccessRuntime.Relational.sql.HighLowRelationalKeyGenerator.IsCached(Connection con, RelationalKeyGeneratorInfoCache infoCache, String tab, String kCol, String vCol, String key, Boolean& ret)

   at OpenAccessRuntime.Relational.sql.HighLowRelationalKeyGenerator.init(String className, RelationalTable theClassTable, Connection con, RelationalKeyGeneratorInfoCache relationalKeyGeneratorInfoCache)

   at OpenAccessRuntime.Relational.RelationalStorageManagerFactory.init(Boolean full) 

I have already removed all the old dll's of 2008 version, i deleted all project dll's that were build with older version, clean the solution after taking reference of newer version of telerik's dll's I rebuild my solution, it buid successfully, but when I m executing a method getting above mentioned error.

Also when I am checking for OQL query in Telerik's browser, its giving error there too I m adding the query that i m using in Telerik's OQL browser ( from visual studio : Telerik -> OpenAccess -> OQL Query Browser...)
Query is : "
SELECT * FROM MtLanguage.csExtent"
and when clicking on "Show SQL" button I m getting following error:


"Could not load file or assembly 'file:///C:\Appli.Net\CPAmemotech6.0\CPAmemotech6
Memotech\Directories\Settings\Languages\bin\Debug\Memotech.Directories.Settings.Languages\Cpa.Common.dll' or one of its dependencies. The system cannot find the file specified.

 

at System.Reflection.Assembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection)

at System.Reflection.Assembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection)

at System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)

at System.Reflection.Assembly.Load(AssemblyName assemblyRef)

at Telerik.OpenAccess.SPI.Util.AssemblyHelper.Load(AssemblyName name)

at Telerik.OpenAccess.Config.References.ReferencesManager.FillReferences(Assembly[] rootAssemblies, AssemblyProvider asmProvider, ReferenceData[] refs)

at Telerik.OpenAccess.Config.ConfigManager.Init()

at Telerik.OpenAccess.DBRegistry.GetDatabase(String urlOrConnectionId, XmlElement configOverride, Assembly[] entryAssemblies)

at Telerik.OpenAccess.Database.Get(String connectionId, XmlElement configOverride, Assembly[] entryAssemblies)

at Telerik.OpenAccess.Sdk.Addin.Query.OQLQueryBrowser.get_Scope()

at Telerik.OpenAccess.Sdk.Addin.Query.OQLQueryBrowser.GetSQL(String query)"

"

Petar it might help to figure out the exact cause of the problem , if u still nedd more information please let me know

Regards,
Dev
CPA Global

0
PetarP
Telerik team
answered on 01 Oct 2009, 01:07 PM
Hello Devanand Chahal,

We could not determine the nature of the first exception given the information you provided. Having that in mind I will have to ask you for some additional hints over your project. What database server are you using? Would it be possible for you to send us your app.config file and the definition of the voa keygen table. Looking into the call stack you provided it seems that the voa keygen is receiving a big decimal number that cannot fit in an integer upon conversation. Maybe you have defined some custom logic over our HighLow key generation mechanism. Any additional information will greatly help us in resolving this problem.
Regarding your second issue, it seems that your project is referencing an assembly that is not available anymore. The exception in the OQL browser can be caused by deleting the assembly that contains your persistent classes and not compiling it again. If that is the case, please recompile the project that holds your persistent classes.

We are looking forward to your replay.
Please note that in order to attach your app.config file, you will need to open a new support thread.

Best wishes,
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.
0
Rahul Masurekar
Top achievements
Rank 1
answered on 24 Mar 2011, 07:53 AM

Hi,

I am facing this problem of not being ble to connect to the local server. Getting this error:

 

"Unable to create RelationalKeyGeneratorFactory instance OpenAccessRuntime.Relational.sql.HighLowRelationalKeyGenerator+Factory"

in the following code:


static public IObjectScope GetNewObjectScope()  
{  
   Database db = Database();  
 
   IObjectScope newScope = db.GetObjectScope();  // This is where it happens
   return newScope;  



0
Ady
Telerik team
answered on 29 Mar 2011, 04:04 PM
Hi Rahul ,

 This typically happens when there is version mismatch in the OpenAccess assemblies. Can you ensure that deployed assemblies are of the same version as the ones you have referenced in your project?
 
Best wishes,
Ady
the Telerik team
0
Renato
Top achievements
Rank 1
answered on 17 Jun 2011, 05:35 PM
Hi,

Under this error, i realize that the main problem is related with different Telerik.OpenAcess.dll versions. Now the thing is, some modules in my site use Dll's who were using different versions of Open Access. For instance i have assembly1.dll who uses  OpenAccess(2010.1.623.5) and assembly2.dll who uses OpenAccess(2011.1.411.2), as OpenAccess made some breaking changes between those two versions it's impossible to just update the reference with the latest OpenAccess.dll, on the other hand and after some several tries i came up with the current scenario: OpenAccess.dll (2010.1.623.5) registered in GAC and OpenAcess.dll(2011.1.411.2) register in the application bin, currently the pages using methods from the dll who calls the old version work fine, but not the pages from the newest module. Finally as the software I'm developing has continuous development it wouldn't make any sense to rewrite the every time we decide to create a new module.

I am looking for some ideas here, as you may have either passed/resolved this issue for other client, and i would say this is a major drawback as this OpenAccess version have only a year difference and seems to be difficult to make them coexist.

0
Ady
Telerik team
answered on 20 Jun 2011, 09:43 AM
Hi Renato,

 We have not come across a similar support ticket before.It is not advisable to have parts of the same application work against different versions of the OpenAccess assemblies. Can you provide some more information about this breaking change that you mentioned? Maybe we can provide you a solution to gracefully migrate your application to the newer version you have.

Looking forward to resolving your issue.

All the best,
Ady
the Telerik team
Q1’11 SP1 of Telerik OpenAccess is available for download; also available is the Q2'11 Roadmap for Telerik OpenAccess ORM.
0
Renato
Top achievements
Rank 1
answered on 20 Jun 2011, 06:41 PM
Hi Ady,

The main difference at this point, is the ObjectScopeProvider (related with 2010.613.5) and the Extent property.

When my team used that 2010 version they would get the data by typing the following code:
public static List<User> ListUsers()
        {
             IObjectScope scope = ObjectScopeProvider1.ObjectScope();
             IQueryable<User> listUser;
             listUser = (from u in scope.Extent<User>()                        
                        select u);
             return listUser.ToList();
}


And now i'm using the 2011.1.411.2  and i use the ModelContext
public static List<User> ListUser(ORMNewVersionModel context)
       {
           IQueryable<User> listUser;
              listUser = (from usr in context.Users
                            select usr
                             );
            return listUser.ToList();
           }

Also my GAC as the assemblies displayed in the image i'm sending to you. For the propose of this thread I took the liberty to create a simple project, and latter on I will create a support ticket, but in the meantime i am getting yet another error, which after a brief search pointed me to another common error when having outdated references the message says "Unable to cast object of type 'Telerik.OpenAccess.RT.Adonet2Generic.Impl.DBDriver' to type 'Telerik.OpenAccess.RT.sql.Driver'."

Thanks for the help, best regards,

Renato
0
Renato
Top achievements
Rank 1
answered on 21 Jun 2011, 11:03 AM
After reading more carefully what Ady said I realized your idea. Basically you advised me to open every single library with the old version and do the OpenAccess update references which at this point i know it will solve my problem. This however seems to be the last option as the old version libraries are already in the client server. What we would prefer was something that would prevent having to rebuild the libraries, we tried just to change the referenced dll and that wouldn't obviously work as this situation was referred in a topic in your forum. So can you please came up with any other suggestion?
0
Ady
Telerik team
answered on 22 Jun 2011, 05:04 PM
Hello Renato,

Based on your previous posts it seems that you have 2 modules - 1 with persistent types created using the 'classic' approach (ObjectScopeProvider used to obtain the scope) and the other created using the new domain model designer (Context used to obtain persistent types). Both these approaches can work with the lastest OpenAccess assemblies. In case you need the version on the client machine to use the latest OpenAccess assemblies without recompiling you can add the 'bindingRedirect' xml entry to the app.config file.

Do get back in case you need further assistance or this resolution does not apply to your problem, in which case you could provide me with exact error you get.


Regards,
Ady
the Telerik team
Q1’11 SP1 of Telerik OpenAccess is available for download; also available is the Q2'11 Roadmap for Telerik OpenAccess ORM.
0
Alberto
Top achievements
Rank 1
answered on 19 Aug 2011, 01:45 PM
Hello.
Im working in the exaclty same problem Renato previously posted.

When trying to do what Ady said in the last post (binding redirect) and Im facing another error, this time in the module with the 'classic' aproach!

When trying to call a method from the 'classic' persisten type I get:
"Method 'OpenAccessEnhancedGetObjectId' in type 'Old.Module.AssemblyName.Class' from assembly 'Old.Module.AssemblyName, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' does not have an implementation."
0
Ady
Telerik team
answered on 24 Aug 2011, 04:10 PM
Hi Alberto,

 Can you provide some more information about the setup of your application? Are different versions of OpenAccess ORM involved? When do you get the exception and maybe you can also provide the call stack of the exception.
All this information will help us in narrowing down the actual cause of the problem.

Looking forward to assisting you further.

All the best,
Ady
the Telerik team

Thank you for being the most amazing .NET community! Your unfailing support is what helps us charge forward! We'd appreciate your vote for Telerik in this year's SQL Server Community Awards. We are competing in TWO categories and every vote counts! VOTE for Telerik NOW >>

0
Erik
Top achievements
Rank 2
answered on 04 Mar 2012, 04:37 PM
Hello,

Well, this all maybe true, but I'm getting this after an upgrade. I solved it by deleting the OA dll's in the debug of the web project and recompile. But the cause is clear: OA upgrade ref does not work on a network location.

I had a project that I "forked" (copied to an other location). Now the first proj is on a network location and the second is on a local HD. Today I did a OA "Upgrade References" on the local proj, and there was no problem. proj where referenced right and where reloaded by themselves. When i did it on the proj on the network, no reloading was done; most ref where upgraded (not all...) and I got 144 errors. after some manual changes i managed to get rid of the errors but then got the error on runtime as mentioned in this post:
Telerik.OpenAccess.OpenAccessException: Unable to create RelationalKeyGeneratorFactory instance    OpenAccessRuntime.Relational.sql.HighLowRelationalKeyGenerator+Factory

This is not the first problem with telerik and network issues btw...

Well, after a hour upgrading, now focus on the dev...

Erik
0
Zoran
Telerik team
answered on 07 Mar 2012, 05:55 PM
Hello everyone,

 Just to update you that there are indeed problems with OpenAccess on network locations, which are not related directly to OpenAccess. Here are some resources that describe the issue:

http://www.acthompson.net/DotNet/setting_a_trusted_location.htm 
http://blogs.msdn.com/b/shawnfa/archive/2004/12/30/344554.aspx 

Thanks to Eric for the valuable input.

Regards,
Zoran
the Telerik team
Telerik OpenAccess ORM Q1 2012 release is here! Check out what's new or download a free trial >>
Tags
Databases and Data Types
Asked by
Jouie
Top achievements
Rank 1
Answers by
Jouie
Top achievements
Rank 1
Devanand Chahal
Top achievements
Rank 2
PetarP
Telerik team
Rahul Masurekar
Top achievements
Rank 1
Ady
Telerik team
Renato
Top achievements
Rank 1
Alberto
Top achievements
Rank 1
Erik
Top achievements
Rank 2
Zoran
Telerik team
Share this question
or