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));
答案 0 :(得分:0)
好吧,这个愚蠢的错误出现在Lambda表达式中。它返回null,因为它在分配值之前尝试计算。傻我。
Domain dbDomain = server.Domains.DefaultIfEmpty(null).FirstOrDefault(a => a.DomainId.Equals(domain.DomainId));
应该是:
Domain dbDomain = server.Domains.Where(a => a.DomainId.Equals(domain.DomainId))DefaultIfEmpty(null).FirstOrDefault();