Domanda

I'm having a real problem trying to set a custom property of a data flow component I've created through a custom form.

The value I'm assigning is just now being set, the custom property either remains the original value or stays null.

In my TaskClass I've overridden the ProvideComponentProperties() method and I've created the custom property as shown below.

IDTSCustomProperty100 componentCustomProperty = ComponentMetaData.CustomPropertyCollection.New();
componentCustomProperty.Name = "PAFProvider";
componentCustomProperty.Description = "PAF Provider";
componentCustomProperty.Value = "testinitial";

I've created a TaskClassUI which inherits from the IDtsComponentUI interface. I implement all required methods.

My Initialise method.

public void Initialize(IDTSComponentMetaData100 dtsComponentMetadata, IServiceProvider serviceProvider)
{
       this._dtsComponentMetaData = dtsComponentMetadata;
            this._serviceprovider = serviceProvider;

}

The implementation of my Edit Method

 public bool Edit(IWin32Window parentWindow, Variables variables, Connections connections)
    {
        bool flag;
        try
        {
            PAFUIMainWnd ui = new PAFUIMainWnd(this._dtsComponentMetaData, this._serviceprovider, connections);
            DialogResult result = ui.ShowDialog(parentWindow);
            bool flag1 = result != DialogResult.OK;
            if(!flag1)
            {
                flag = true;
                return flag;
            }
        }
        catch(Exception exe)
        {
            MessageBox.Show(exe.ToString());
        }
        flag = false;
        return flag;            
    }

And the implementation of my UIFORM.

public PAFUIMainWnd(IDTSComponentMetaData100 iDTSComponentMetaData100, IServiceProvider serviceProvider, Connections connections)
        {            
            this.components = null;
            this.InitializeComponent();
            this._dtsComponentMetaData = iDTSComponentMetaData100;     
            this._designTimeComponent = this._dtsComponentMetaData.Instantiate();
            textBox1.Text = _dtsComponentMetaData.CustomPropertyCollection["PAFProvider"].Value.ToString();

        }

And just for testing purposes I've stuck a textbox and a button on my form. The OnClick even for the button is below. I'm just taking the value from the textbox and assigning it to the Custom Property but its not assigning it. I can read the original value from the Custom Property which I assign to the text box. I just dont understand why I can't assign it. I've followed the MSDN and various other examples through completely. If anyone can point out what I've done wrong I would be very greatful. Its gotten to the head banging stage.

 private void btnOK_Click(object sender, EventArgs e)
    {
       _designTimeComponent.SetComponentProperty("PAFProvider", textBox1.Text);           

        this.Close();
    }
È stato utile?

Soluzione

A restart fixed this. The code was perfectly fine.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top