Hello all,
I want to iterate over all Itemtypes in a all Libraries but I get an Memory Exception in the second iteration in following Code:
try { ItemTypeLibraryPtr itemTypeLibrary = ItemTypeLibrary::FindByName(libName.c_str(), *ISessionMgr::GetActiveDgnFile()); for (ItemTypeLibrary::iterator iter = itemTypeLibrary->begin(); iter != itemTypeLibrary->end(); ++iter) { if (WString::IsNullOrEmpty(iter->GetName())) continue; auto name = iter-> GetName(); } } catch (...) { printf("Error\n"); }
The Exception appears when I try to retrieve the name or the internalName of the Item Type:
The Try - catch Block is not throwing aswell.
Am I using the iterator in wrong way or is there an alternative possibility to retrieve the Names of all Itemtypes in a library?
Thanks in advance
Manu
Manuel Höger said:I want to iterate over all Itemtypes in a all LibrariesItemTypeLibrary::FindByName
ItemTypeLibrary::FindByName
Does that return a valid pointer? Test itemTypeLibrary.IsValid()
itemTypeLibrary.IsValid()
Regards, Jon Summers LA Solutions
Yes it does. I tried this before. And any other possibility of exception handling I know to get around this error.
It appears often at the second iteration. Means my library has two Itemtypes. The first Typename is resolved without problems and the second gives this error.
With very similar code I iterate through all libraries without a problem.
Maybe if you provide a sample dgn (instance) and dgnlib (definitions) as a test case, we can reproduce the issue, review and make recommendations with those details.
Bob
I didn't use a dgnlib. I directly created the Itemtypes in the Dgn with the MS Itemtype Dialog.
But the problem appears with Definitions in a dgn lib aswell. I tried it just now.
Your answer leads me to the suggestion that there haven't been any problems with the iterators right now and you couldn't reproduce it?
I will prepare a testcase example next week.
Thanks again