Author Topic: workaround to missing DictionaryEntry in 2006 .net api?  (Read 3701 times)

0 Members and 1 Guest are viewing this topic.

jmaeding

  • Bull Frog
  • Posts: 304
  • I'm just here for the Shelties.
workaround to missing DictionaryEntry in 2006 .net api?
« on: August 15, 2008, 12:52:48 PM »
I was using code to grab the images from a drawing, and tried it on 06.
I got an error that the dbDictionaryEntry could not be found in the acdbmgd.dll and went to check in the object browser in VS.
I had not noticed this before, because my references are set to the 2008 versions, and I test on 2008 generally.
Sure enough, set to 06 versions and it ain't there.  I hate it when the computer knows what its talking about.

I went back and looked at code from Tony T and Tim W, and realized there might be a good reason they used dxf codes to look through images.
Was this the reason, or is there some dll import step I need to do to get the ability to look at dictionaryentries in 2006?
thanks as always.
James Maeding

It's Alive!

  • Retired
  • Needs a day job
  • Posts: 8704
  • AKA Daniel
Re: workaround to missing DictionaryEntry in 2006 .net api?
« Reply #1 on: August 15, 2008, 01:25:07 PM »
Sorry I’m a little slow today  :mrgreen: What images? Do you have a link or code or something I can look at?

T.Willey

  • Needs a day job
  • Posts: 5251
Re: workaround to missing DictionaryEntry in 2006 .net api?
« Reply #2 on: August 15, 2008, 01:39:57 PM »
If you're looking for DictionaryEntry, then you have to have a call to System.Collections.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

jmaeding

  • Bull Frog
  • Posts: 304
  • I'm just here for the Shelties.
Re: workaround to missing DictionaryEntry in 2006 .net api?
« Reply #3 on: August 15, 2008, 01:47:14 PM »
sorry, here is the snippet that works for 08, but not 06...
Code: [Select]
                    ObjectId ImgDictId = RasterImageDef.GetImageDictionary(db);
                    if (ImgDictId != ObjectId.Null) {
                        DBDictionary ImgDict = (DBDictionary)tr.GetObject(ImgDictId, OpenMode.ForRead);
                        if (ImgDict.Count != 0) {
                            foreach (DBDictionaryEntry de in ImgDict) {
                                string ImName = de.Key as string;
                                ObjectId ObjId = (ObjectId)de.Value;
                                RasterImageDef rid = tr.GetObject(ObjId, OpenMode.ForRead) as RasterImageDef;
                                ....

I cannot foreach with 06.  I'm not good enough with .net to know if its just a matter of getting the dictentry a different way, or if I need to approach it totally differently, like using dxf codes (non-.net api methods...)
James Maeding

T.Willey

  • Needs a day job
  • Posts: 5251
Re: workaround to missing DictionaryEntry in 2006 .net api?
« Reply #4 on: August 15, 2008, 01:54:44 PM »
That could be why I used this line of code in my '06 code that I sent you.

foreach (DictionaryEntry de in ImgDict) {
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

Glenn R

  • Guest
Re: workaround to missing DictionaryEntry in 2006 .net api?
« Reply #5 on: August 15, 2008, 03:51:09 PM »
Yep. '06 used the native .net System.Collections.DictionaryEntry to represent the values stored in a DBDictionary. It appears that later versions use a custom class called DBDictionaryEntry...probably to return a strongly typed ObjectId and whatnot.

jmaeding

  • Bull Frog
  • Posts: 304
  • I'm just here for the Shelties.
Re: workaround to missing DictionaryEntry in 2006 .net api?
« Reply #6 on: August 15, 2008, 04:14:55 PM »
oh, DB prefix missing, now I see.
Stuff all starts to look the same after a while.
Thanks Tim and Glen
James Maeding

Glenn R

  • Guest
Re: workaround to missing DictionaryEntry in 2006 .net api?
« Reply #7 on: August 15, 2008, 04:22:19 PM »
Have a look in reflector and see if DBDictionaryEntry is Derived from DictionaryEntry....if it is you could probably use it in all code....

Glenn R

  • Guest
Re: workaround to missing DictionaryEntry in 2006 .net api?
« Reply #8 on: August 15, 2008, 04:38:57 PM »
Scratch that. The '08 docs refer to this as lightweight which made me suspicious. So after looking in Reflector, my suspicions were confirmed. DBDictionaryEntry derives from System.ValueType and it's a struct...hence the lightweight term.

This is actually good, because value types are generally on the stack, not the managed heap and it's small....i'm being very general here :D

jmaeding

  • Bull Frog
  • Posts: 304
  • I'm just here for the Shelties.
Re: workaround to missing DictionaryEntry in 2006 .net api?
« Reply #9 on: August 15, 2008, 05:45:55 PM »
hmm, I changed my code for 2006 to use the DicitonaryEntry object, but now I get an error that I cannot foreach through the Dictionary object because it does not have a GetEnumerator method in the 06 api.

I checked in the object browser, and again it is correct.
Tim, was your code for 2007 or something?  I looked and looked at the code but cannot see how it would have worked for you.  I'm stumped again.
thanks
James Maeding

jmaeding

  • Bull Frog
  • Posts: 304
  • I'm just here for the Shelties.
Re: workaround to missing DictionaryEntry in 2006 .net api?
« Reply #10 on: August 15, 2008, 05:46:56 PM »
I meant "cannot foreach through the DBDictionary object named ImgDict"....
James Maeding

jmaeding

  • Bull Frog
  • Posts: 304
  • I'm just here for the Shelties.
Re: workaround to missing DictionaryEntry in 2006 .net api?
« Reply #11 on: August 15, 2008, 06:03:06 PM »
shoot, ignore that post.
I discovered that changing the acad dll references to the 2006 versions solved it.
I thought that did not matter, as it finds the versions needed per a given version.
Maybe VS 2008 handles it a bit differently than 2005 did.
James Maeding