- Home
- LLBLGen Pro
- Bugs & Issues
Getting error with 2.5 {"Key cannot be null.\r\nParameter name: key"}
Joined: 19-May-2006
HI,
I am already working with LLBLGen 2.0 [Self Servicing]. I migrated my code to 2.5 today , almost everything worked fine except this one
i am sending you error stack
{System.ArgumentNullException: Key cannot be null. Parameter name: key at System.Collections.Hashtable.Insert(Object key, Object nvalue, Boolean add) at System.Collections.Hashtable.set_Item(Object key, Object value) at SD.LLBLGen.Pro.ORMSupportClasses.DaoBase.DetermineDifferentValuesForParameterizedPPath(IEntityCollection rootEntities, IPrefetchPath prefetchPath, IPrefetchPathElement currentElement, Int32& amountRootEntitiesUsable) at SD.LLBLGen.Pro.ORMSupportClasses.DaoBase.FetchPrefetchPath(IEntityCollection rootEntities, IPredicate filter, IRelationCollection relations, Int64 maxNumberOfItemsToReturn, ISortExpression sortClauses, IPrefetchPath prefetchPath, ITransaction containingTransaction, Boolean forceParameterizedPPath) at SD.LLBLGen.Pro.ORMSupportClasses.DaoBase.PerformFetchEntityAction(IEntity entityToFetch, ITransaction containingTransaction, IPredicateExpression selectFilter, IPrefetchPath prefetchPathToUse, Context contextToUse, ExcludeIncludeFieldsList excludedIncludedFields) at Avalara.AvaTax.Data.Account.DaoClasses.CompanyDAO.FetchCompanyUsingUCAccountIdCompanyCode(IEntity entityToFetch, ITransaction containingTransaction, Int32 accountId, String companyCode, IPrefetchPath prefetchPathToUse, Context contextToUse, ExcludeIncludeFieldsList excludedIncludedFields) in D:\Projects\AvaTax\src\Data\Account\DaoClasses\CompanyDAO.cs:line 69 at Avalara.AvaTax.Data.Account.EntityClasses.CompanyEntityBase.FetchUsingUCAccountIdCompanyCode(Int32 accountId, String companyCode, IPrefetchPath prefetchPathToUse, Context contextToUse, ExcludeIncludeFieldsList excludedIncludedFields) in D:\Projects\AvaTax\src\Data\Account\EntityBaseClasses\CompanyEntityBase.cs:line 749 at Avalara.AvaTax.Data.Account.EntityClasses.CompanyEntityBase.FetchUsingUCAccountIdCompanyCode(Int32 accountId, String companyCode, IPrefetchPath prefetchPathToUse) in D:\Projects\AvaTax\src\Data\Account\EntityBaseClasses\CompanyEntityBase.cs:line 718 at Avalara.AvaTax.Services.Account.Rules.CompanyParentRule.Apply(Int32 accountId, Int32 companyId, String companyCode, Int32 parentId, String refersTo, BaseResult result) in D:\Projects\AvaTax\src\Services\Account\Rules\CompanyParentRule.cs:line 42 at Avalara.AvaTax.Services.Account.Entities.Company.Validate(String refersTo, BaseResult result) in D:\Projects\AvaTax\src\Services\Account\Entities\Company.cs:line 514 at Avalara.AvaTax.Services.Account.AccountSvc.CompanySave(Company Company) in D:\Projects\AvaTax\src\Services\Account\AccountSvc.asmx.cs:line 1031}
I am trying following things when i receive above error
companyEntity.FetchUsingUCAccountIdCompanyCode(accountId, companyCode, prefetchPath);
THE SAME PIECE OF CODE USED TO WORK WITH 2.0.
i tried debugging in the auto generated code of LLBLGen and found following things.. it may help you in trouble shooting or reproducing the issue
in llblgenerated file CompanyEntityBase.cs
the code runs through a switch case sequence i think the code is failing somewhere around here case "Children": _alreadyFetchedChildren = true; //Ammit's Comment : here the entity comes as //null and then code returns the error as mentioned above
if(entity!=null)
{
this.Children.Add((CompanyEntity)entity);
}
break;
I will try doing some work around for this issue for now and will stop using
FetchUsingUCAccountIdCompanyCode
and will use the .getMulti() by adding appripriate conditions.
Let me know your feedback for the same
Thanks Ammit
Joined: 19-May-2006
Hey.. Update to the issue i reported. I mentioned about taking a work around and i did that and suprisingly it worked fine. I am suprised how it worked though attaching a snippet
this was the original code which generated error --> companyEntity.FetchUsingUCAccountIdCompanyCode(accountId, companyCode, prefetchPath);
then I replaced it with the usual GetMulti() thing and it worked CompanyCollection companyCollection = new CompanyCollection(); IPredicateExpression filter = new PredicateExpression(); filter.Add(PredicateFactory.CompareValue(CompanyFieldIndex.AccountId, ComparisonOperator.Equal, accountId)); filter.Add(PredicateFactory.CompareValue(CompanyFieldIndex.CompanyCode, ComparisonOperator.Equal, companyCode)); companyCollection.GetMulti(filter,prefetchPath);
Suprisingly when i was degugging i found the similar code in CompanyDao.cs
public void FetchCompanyUsingUCAccountIdCompanyCode(IEntity entityToFetch, ITransaction containingTransaction, System.Int32 accountId, System.String companyCode, IPrefetchPath prefetchPathToUse, Context contextToUse, ExcludeIncludeFieldsList excludedIncludedFields) { IPredicateExpression selectFilter = new PredicateExpression(); selectFilter.Add(new FieldCompareValuePredicate(entityToFetch.Fields[(int)CompanyFieldIndex.AccountId], ComparisonOperator.Equal, accountId)); selectFilter.Add(new FieldCompareValuePredicate(entityToFetch.Fields[(int)CompanyFieldIndex.CompanyCode], ComparisonOperator.Equal, companyCode)); PerformFetchEntityAction(entityToFetch, containingTransaction, selectFilter, prefetchPathToUse, contextToUse, excludedIncludedFields); }
Internally companyEntity.FetchUsingUCAccountIdCompanyCode(accountId, companyCode, prefetchPath); is doing the same thing as i explicitely wrote in work around..
Can you throw some light on this???
Ammit wrote:
HI,
I am already working with LLBLGen 2.0 [Self Servicing]. I migrated my code to 2.5 today , almost everything worked fine except this one
i am sending you error stack
{System.ArgumentNullException: Key cannot be null. Parameter name: key at System.Collections.Hashtable.Insert(Object key, Object nvalue, Boolean add) at System.Collections.Hashtable.set_Item(Object key, Object value) at SD.LLBLGen.Pro.ORMSupportClasses.DaoBase.DetermineDifferentValuesForParameterizedPPath(IEntityCollection rootEntities, IPrefetchPath prefetchPath, IPrefetchPathElement currentElement, Int32& amountRootEntitiesUsable) at SD.LLBLGen.Pro.ORMSupportClasses.DaoBase.FetchPrefetchPath(IEntityCollection rootEntities, IPredicate filter, IRelationCollection relations, Int64 maxNumberOfItemsToReturn, ISortExpression sortClauses, IPrefetchPath prefetchPath, ITransaction containingTransaction, Boolean forceParameterizedPPath) at SD.LLBLGen.Pro.ORMSupportClasses.DaoBase.PerformFetchEntityAction(IEntity entityToFetch, ITransaction containingTransaction, IPredicateExpression selectFilter, IPrefetchPath prefetchPathToUse, Context contextToUse, ExcludeIncludeFieldsList excludedIncludedFields) at Avalara.AvaTax.Data.Account.DaoClasses.CompanyDAO.FetchCompanyUsingUCAccountIdCompanyCode(IEntity entityToFetch, ITransaction containingTransaction, Int32 accountId, String companyCode, IPrefetchPath prefetchPathToUse, Context contextToUse, ExcludeIncludeFieldsList excludedIncludedFields) in D:\Projects\AvaTax\src\Data\Account\DaoClasses\CompanyDAO.cs:line 69 at Avalara.AvaTax.Data.Account.EntityClasses.CompanyEntityBase.FetchUsingUCAccountIdCompanyCode(Int32 accountId, String companyCode, IPrefetchPath prefetchPathToUse, Context contextToUse, ExcludeIncludeFieldsList excludedIncludedFields) in D:\Projects\AvaTax\src\Data\Account\EntityBaseClasses\CompanyEntityBase.cs:line 749 at Avalara.AvaTax.Data.Account.EntityClasses.CompanyEntityBase.FetchUsingUCAccountIdCompanyCode(Int32 accountId, String companyCode, IPrefetchPath prefetchPathToUse) in D:\Projects\AvaTax\src\Data\Account\EntityBaseClasses\CompanyEntityBase.cs:line 718 at Avalara.AvaTax.Services.Account.Rules.CompanyParentRule.Apply(Int32 accountId, Int32 companyId, String companyCode, Int32 parentId, String refersTo, BaseResult result) in D:\Projects\AvaTax\src\Services\Account\Rules\CompanyParentRule.cs:line 42 at Avalara.AvaTax.Services.Account.Entities.Company.Validate(String refersTo, BaseResult result) in D:\Projects\AvaTax\src\Services\Account\Entities\Company.cs:line 514 at Avalara.AvaTax.Services.Account.AccountSvc.CompanySave(Company Company) in D:\Projects\AvaTax\src\Services\Account\AccountSvc.asmx.cs:line 1031}
I am trying following things when i receive above error
companyEntity.FetchUsingUCAccountIdCompanyCode(accountId, companyCode, prefetchPath);
THE SAME PIECE OF CODE USED TO WORK WITH 2.0.
i tried debugging in the auto generated code of LLBLGen and found following things.. it may help you in trouble shooting or reproducing the issue
in llblgenerated file CompanyEntityBase.cs
the code runs through a switch case sequence i think the code is failing somewhere around here case "Children": _alreadyFetchedChildren = true; //Ammit's Comment : here the entity comes as //null and then code returns the error as mentioned above
if(entity!=null) { this.Children.Add((CompanyEntity)entity); } break;
I will try doing some work around for this issue for now and will stop using
FetchUsingUCAccountIdCompanyCode
and will use the .getMulti() by adding appripriate conditions.
Let me know your feedback for the same
Thanks Ammit
Joined: 21-Aug-2005
companyEntity.FetchUsingUCAccountIdCompanyCode(accountId, companyCode, prefetchPath);
I think it had something to do with the passed in PrefetchPath, would you please post the prefetchPath code.
Also which version of LLBLGen Pro reuntime library are you using? As it sounds like a bug that was solved on the 11th of September, as stated in the ChangeLog History page. Would you please try using the latest version?
Joined: 19-May-2006
Walaa wrote:
companyEntity.FetchUsingUCAccountIdCompanyCode(accountId, companyCode, prefetchPath);
I think it had something to do with the passed in PrefetchPath, would you please post the prefetchPath code.
Also which version of LLBLGen Pro reuntime library are you using? As it sounds like a bug that was solved on the 11th of September, as stated in the ChangeLog History page. Would you please try using the latest version?
Hi the version i have is as follows Property of SD.LLBLGen.Pro.DQE.SqlServer.NET20.dll says
Created on Tuesday, October 16, 2007, 4:32:25 PM Modified on Thursday, September 06, 2007, 3:36:10 PM
Assembly Version 2.5.0.0 File Version 2.5.7.906 File Size 36.0 KB (36,864 bytes)
i tried using this and it sitll gives me the same problem. though i have adopted the work around and looks like it is working fine Code for building prefetch path
CompanyEntity companyEntity = new CompanyEntity();
IPrefetchPath prefetchPath = new PrefetchPath((int)EntityType.CompanyEntity);
prefetchPath.Add(CompanyEntity.PrefetchPathChildren);
thanks Ammit