English 中文(简体)
自定义TFS Web服务插件出现问题
原标题:Problem with Custom TFS Web Service Plugin

i m not sure that what im going to do is the right so i first of all tell you my issue. I have TFS as Bugtracking System and another system for tracking the worktime. I want that if a workitem status changes the other system changes the status too.

到目前为止,我所做的如下。

当我捕捉到WorkItemChangedEvent时,我为TFS web服务编写了一个插件。

 public EventNotificationStatus ProcessEvent(TeamFoundationRequestContext requestContext, NotificationType notificationType, object notificationEventArgs, 
                                                    out int statusCode, out string 
statusMessage, out ExceptionPropertyCollection properties)   
        {
            statusCode = 0;
            properties = null;
            statusMessage = String.Empty;
            try
            {
                if (notificationType == NotificationType.Notification && notificationEventArgs is WorkItemChangedEvent)
                {
                    WorkItemChangedEvent ev = notificationEventArgs as WorkItemChangedEvent;
                    EventLog.WriteEntry("WorkItemChangedEventHandler", "WorkItem " + ev.WorkItemTitle + " was modified");
                }

            }
            catch (Exception)
            {
            }
            return EventNotificationStatus.ActionPermitted;
        }

I droped the DLL in C:Program FilesMicrosoft Team Foundation Server 2010Application TierWeb ServicesinPlugins but i looks like the extension is never called. So nothing apears in the event log.

But if i try to debug the service like in this post http://geekswithblogs.net/jakob/archive/2010/10/27/devleoping-and-debugging-server-side-event-handlers-in-tfs-2010.aspx i cant hook on the process. So debugging does not work. Why i cant debug the service? And is there a better way to do this?

最佳回答

若要调试w3wp.exe进程,您需要以管理员身份运行Visual Studio。

  • From the menu, select Debug > Attach to process (or Ctrl-Alt-P)
  • Select Show processes from all users and Show processes in all sessions.
  • Find the w3wp.exe process that corresponds to your TFS Application Pool, and attach to it.

我注意到您正在使用EventLog.WriteEntry()-您之前在代码中注册过事件源吗?为了避免注册(这需要管理员权限),您可以尝试使用TFS记录器:

TeamFoundationApplication.Log(“WorkItem”+ev.WorkItemTitle+“已修改”,0,System.Diagnostics.EventLogEntryType.Information)

问题回答

不确定您是否修复了此问题,但在我看来,类中似乎缺少Subscription方法。

public Type[] SubscribedTypes()
{
    return new Type[1] {typeof(WorkItemChangedEvent)};
}

没有这个,你的插件永远不会被击中,因此你将无法调试。





相关问题
Why not use TFS as a build / CI solution?

Currently our build solution is set up using TFS + MS Build scripts. TFS is also being used as a CI server. I ve seen several posts on this site telling people about other CI solutions. Are there ...

Get files from TFS under Linux [closed]

is there a free (command line) tool for linux which with I can get all files from a TFS-Repository (no Check in / Check out required - only get actual version)?

upgrading tfs 2008 sp1 to use sql server 2008

I have an instance of tfs 2008 supported by sql server 2005. I want to change the sql server machine by doing a restore based move. I also want to change the version of sql server to 2008. I know ...

Using Git in a TFS shop

Using Git at home has spoiled me - I now find using TFS at work to be a bit of a drag and want to explore the possibility of using Git locally and syncing somehow with TFS. I figure there are a few ...

TFSReg in 2010 Beta 2?

does anybody know what is the equivalent of the TFSReg.exe command-line tool in 2010 Beta 2? I cannot find it anywhere, I searched the entire Program Files tree. Was it renamed? Moved? Replaced by ...