WorkItemStore null reference

Hi,

i checked this forum and other sources, but couldnt find any solution for my problem. I have web service and asp.net 2.0 web to access TFS work item store, so my customers can add issues directly to the TFS. It works fine except one small issue.

protected void Application_Start(Object sender, EventArgs e)
{
TeamFoundationServer tfsConn = null;

try
{
tfsConn = new TeamFoundationServer(Config.TeamFoundationServer());
}
catch (Exception ex)
{
throw ex;
}
if (tfsConn == null)
throw new Exception("Team Foundation Server Connection was not succesfull!");
Application["tfsConnector"] = tfsConn;

WorkItemStore store = null;
// THIS IS NOT GOOD!!!
int i = 100;
while (store == null) // TODO there must be better way to do this
{
try
{

i--;
store = (WorkItemStore)tfsConn.GetService(typeof(WorkItemStore));
}
catch
{
if (i == 0) throw new Exception("Store connection error!");
}
}
Application["workItemStore"] = store;
}

This is part of my code in global.asax.cs of web service. I know, its totaly WRONG way how to do that, but i didn't find any better way.

store = (WorkItemStore)tfsConn.GetService(typeof(WorkItemStore));

This line is returning NULL for couple times after web service is started. I don't have idea why.

Thanks for any help

[1572 byte] By [FiLCoN] at [2008-2-14]
# 1

You can try:

TeamFoundationServer server = TeamFoundationServerFactory.GetServer("servername");

WorkItemStore wiStore = new WorkItemStore(server);

There are a few configuration steps you need to take to get Work Item Tracking working in a web environment. Check out :

http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=287237&SiteID=1

for details.

Hope it helps.

ChandruR at 2007-9-9 > top of Msdn Tech,Visual Studio Team System,Team Foundation Server - Work Item Tracking...

Visual Studio Team System

Site Classified