Custom Work Item Control not working in Visual Studio 2015 TFS 2013

时间:2015-09-01 21:24:31

标签: visual-studio tfs visual-studio-2015 tfs2013

I have a simple custom work item control that works flawlessly in VS 2013. I recently installed VS 2015 on my Windows 10 box and the control throws an error like so:

TF400939: The custom control type 'TimSheetsControl.WITimeSheetControl' does not implement the IWorkItemControl interface or is compiled for a different version of Visual Studio.

This is frustrating because the control does implement IWorkItemControl Interface. Also compiling to a version of Visual Studio doesn't seem to be a thing, at least as far as I understand it.

I tried to create a very simple control (just a ComboBox on a screen) to do some testing and I got exactly the same error.

I guess I have a couple questions:

  1. Should I be doing this type of custom control in Visual Studio anymore? Or should I be creating web controls to replace what was once done in Visual Studio.
  2. Is there something I'm doing terribly wrong which is causing this to fail?

The very simple control code I created is below, I'm happy to answer questions about my environment if that information is useful.

Thanks for your time and attention.

UserControl Code Behind (WITimeSheetControl):

namespace TimSheetsControl
{
    public partial class WITimeSheetControl : UserControl, IWorkItemControl
    {
        private object WorkItemDataSource;
        protected IServiceProvider ServiceProvider = null;
        public WITimeSheetControl()
        {
            InitializeComponent();
        }

        public StringDictionary Properties{get; set;}

        public bool ReadOnly { get; set; }

        public object WorkItemDatasource
        {
            get
            {
                return WorkItemDataSource;
            }

            set
            {
                WorkItemDataSource = value;
            }
        }

        public string WorkItemFieldName { get; set; }

        public event EventHandler AfterUpdateDatasource;
        public event EventHandler BeforeUpdateDatasource;

        public void Clear()
        {

        }

        public void FlushToDatasource()
        {
        }

        public void InvalidateDatasource()
        {
            if (string.IsNullOrEmpty(WorkItemFieldName))
            {
                throw new ArgumentNullException("The fieldname property for the WITimeSheetControl is not set.");
            }

            cmbPosition.SelectedIndex = -1;
        }

        public void SetSite(IServiceProvider serviceProvider)
        {
            ServiceProvider = serviceProvider;
        }
    }
 }

UserControl Designer Code:

namespace TimSheetsControl
{
    partial class WITimeSheetControl
    {
        /// <summary> 
        /// Required designer variable.
        /// </summary>
        private System.ComponentModel.IContainer components = null;

        /// <summary> 
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing && (components != null))
            {
                components.Dispose();
            }
            base.Dispose(disposing);
        }

        #region Component Designer generated code

        /// <summary> 
        /// Required method for Designer support - do not modify 
        /// the contents of this method with the code editor.
        /// </summary>
        private void InitializeComponent()
        {
            this.cmbPosition = new System.Windows.Forms.ComboBox();
            this.SuspendLayout();
            // 
            // cmbPosition
            // 
            this.cmbPosition.DropDownWidth = 145;
            this.cmbPosition.FormattingEnabled = true;
            this.cmbPosition.Items.AddRange(new object[] {
            "Business Analyst",
            "Programmer"});
            this.cmbPosition.Location = new System.Drawing.Point(139, 23);
            this.cmbPosition.MaximumSize = new System.Drawing.Size(165, 0);
            this.cmbPosition.Name = "cmbPosition";
            this.cmbPosition.Size = new System.Drawing.Size(151, 21);
            this.cmbPosition.TabIndex = 0;
            // 
            // WITimeSheetControl
            // 
            this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
            this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
            this.Controls.Add(this.cmbPosition);
            this.Name = "WITimeSheetControl";
            this.Size = new System.Drawing.Size(1219, 565);
            this.ResumeLayout(false);

        }

        #endregion

        private System.Windows.Forms.ComboBox cmbPosition;
    }
}

wicc:

<?xml version="1.0" encoding="utf-8" ?>
<CustomControl xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <Assembly>TimSheetsControl.dll</Assembly>
    <FullClassName>TimSheetsControl.WITimeSheetControl</FullClassName>
</CustomControl>

1 个答案:

答案 0 :(得分:6)

您需要编译一个针对TFS 2015二进制文件的自定义控件版本,以便在VS 2015中加载控件。