
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi!
I have the following lines of C# code:
foreach (ObjectId attID in titleBlock.AttributeCollection)
{
AttributeReference attRef = (AttributeReference)attID.GetObject(OpenMode.ForRead);
if (String.Equals(attRef.Tag, UserPreferences.Instance.ABC, StringComparison.OrdinalIgnoreCase))
{
vendorIP = false;
}
...
I am trying to figure out why GetObject keeps throwing me the exception "System.NullReferenceException: Object reference not set to an instance of an obj." attID is not Null. The documentation for GetObject indicates that it is looking for and object with the objectID of attID in attID. That doesn't make sense to me. For the code I really only need attRef.Tag which is a string. I could circumvent the this exception by just getting the Tag from attID. I'm confused and would like to ask for some guidance on how to eliminate this exception. BTW I did not write this code myself and my C# skills are just intermediate. Thanks in advance!
Solved! Go to Solution.