Specified cast is not valid

Posts   
 
    
sparmar2000 avatar
Posts: 341
Joined: 30-Nov-2003
# Posted on: 05-Jul-2005 13:53:31   

Hi Frans,

I have started to get the above exception recently after regenerating my LLBLPro data access layer.

The full exception is:


{System.InvalidCastException}
    [System.InvalidCastException]: {System.InvalidCastException}
    HelpLink: Nothing
    InnerException: Nothing
    Message: "Specified cast is not valid."
    Source: "Oracle.DataAccess"
    StackTrace: "   at Oracle.DataAccess.Client.OracleCommand.System.Data.IDbCommand.set_Connection(IDbConnection value)
   at SD.LLBLGen.Pro.ORMSupportClasses.Query..ctor(IDbConnection connectionToUse, IDbCommand commandToUse)
   at SD.LLBLGen.Pro.ORMSupportClasses.RetrievalQuery..ctor(IDbConnection connectionToUse, IDbCommand commandToUse)
   at SD.LLBLGen.Pro.DQE.Oracle.DynamicQueryEngine.CreateSelectDQ(IEntityFieldCore[] selectList, IFieldPersistenceInfo[] fieldsPersistenceInfo, IDbConnection connectionToUse, IPredicate selectFilter, Int64 maxNumberOfItemsToReturn, ISortExpression sortClauses, IRelationCollection relationsToWalk, Boolean allowDuplicates, IGroupByCollection groupByClause, Int32& uniqueMarker)
   at SD.LLBLGen.Pro.DQE.Oracle.DynamicQueryEngine.CreateSelectDQ(IEntityFieldCore[] selectList, IFieldPersistenceInfo[] fieldsPersistenceInfo, IDbConnection connectionToUse, IPredicate selectFilter, Int64 maxNumberOfItemsToReturn, ISortExpression sortClauses, IRelationCollection relationsToWalk, Boolean allowDuplicates, IGroupByCollection groupByClause, Int32 pageNumber, Int32 pageSize)
   at SD.LLBLGen.Pro.DQE.Oracle.DynamicQueryEngine.CreateSelectDQ(IEntityFields selectList, IDbConnection connectionToUse, IPredicate selectFilter, Int64 maxNumberOfItemsToReturn, ISortExpression sortClauses, IRelationCollection relationsToWalk, Boolean allowDuplicates, IGroupByCollection groupByClause, Int32 pageNumber, Int32 pageSize)
   at EXDAL.DaoClasses.SYSTEMDETAILSDAO.CreateAndRunMultiInstanceRetrievalQuery(IEntityFields fieldsToReturn, ITransaction containingTransaction, IEntityCollection collectionToFill, Int64 maxNumberOfItemsToReturn, ISortExpression sortClauses, IEntityFactory entityFactoryToUse, IPredicate selectFilter, IValidator validatorToUse, IRelationCollection relations, Int32 pageNumber, Int32 pageSize)
   at EXDAL.DaoClasses.SYSTEMDETAILSDAO.GetMulti(ITransaction containingTransaction, IEntityCollection collectionToFill, Int64 maxNumberOfItemsToReturn, ISortExpression sortClauses, IEntityFactory entityFactoryToUse, IValidator validatorToUse, IPredicate selectFilter, IRelationCollection relations, Int32 pageNumber, Int32 pageSize)
   at EXDAL.CollectionClasses.SYSTEMDETAILSCollection.GetMulti(IPredicate selectFilter, Int64 maxNumberOfItemsToReturn, ISortExpression sortClauses, IRelationCollection relations, Int32 pageNumber, Int32 pageSize)
   at EXDAL.CollectionClasses.SYSTEMDETAILSCollection.GetMulti(IPredicate selectFilter)
   at Business.Components.LoginManager.GetLoginPageMessage() in D:\DotNet\ADE\ExpensesSample\src\Components\LoginManager.vb:line 458"
    TargetSite: {System.Reflection.RuntimeMethodInfo}

Sorry its a bit ugly...and messy, but I could not attach a file to show the stack.

Can you please help?

Regards.

sparmar2000 avatar
Posts: 341
Joined: 30-Nov-2003
# Posted on: 05-Jul-2005 16:30:25   

Hi Frans, Looks like I have discovered what the problem was.

I installed Oracle Developer Tools for VS.Net. This installed the latest version of ODP. At this point I had not regenerated the data access layer using (DAL) LLBLPro and all was fine.

However, later on, I regenerated the DAL, and things stoped working and I got the above exception.

I then deinstalled the latest ODP, and regenerated the code. At this point , VS was telling me that the 'new' DAL project referance to Oracle.DataAccess was in error. I found this in the {Oraclehome}/bin directory, rebuilt the solution and now it seems to be fine.

Just thought you might like to know about this.

Otis avatar
Otis
LLBLGen Pro Team
Posts: 39933
Joined: 17-Aug-2003
# Posted on: 05-Jul-2005 21:04:38   

Some of the ODP.NET versions don't install a policy file, so calls don't get redirected to the right assembly and .net can't find the assembly to load and fails. Rule of thumb with ODP.NET related code is: install the official version from the otn.oracle.com site simple_smile

Frans Bouma | Lead developer LLBLGen Pro