0

I'm using the TFS api to pull data on some projects into a localized database. Recently this stopped working. and gave us this error.

Object Not Set to Reference of an Object

AND

Null reference exception at the Domain level (this fails the moment it connects)

We are pulling down the hierarchy.

Domain - Collection - Project - Requirements... etc.

Debugging I find that I the code can see the domains but not grab them or anything under them. I am perplexed as to what might have caused this. Our dlls are all up to date with the version of TFS being used (Version 12). Thought it might be a credential issue, but this occurs with any credentials used. I've read that it could be a cache issue with the server side credentials somehow. But I do not have access to this.

I would post code, but I am unsure which part would be the most helpful as the connector method works... just fails when it connects so the problem appears to be elsewhere.

Thoughts?

UPDATE:

I have detected the line of code where we have a failure... but walking through it the code detects all TFS items. Domains, test cases, projects. Everything.

But will always return the Null Reference Exception. Keep in mind this has worked seemlessly for months.

 Domain dbDomain = server.Domains.DefaultIfEmpty(null).FirstOrDefault(a => a.DomainId.Equals(domain.DomainId));
Randy B.
  • 453
  • 4
  • 20

1 Answers1

0

Okay so the stupid mistake was in the Lambda expression. It was returning null because it was trying to calculate before a value was assigned. Silly me.

 Domain dbDomain = server.Domains.DefaultIfEmpty(null).FirstOrDefault(a => a.DomainId.Equals(domain.DomainId));

Should be:

Domain dbDomain = server.Domains.Where(a => a.DomainId.Equals(domain.DomainId))DefaultIfEmpty(null).FirstOrDefault();
Randy B.
  • 453
  • 4
  • 20