views:

16

answers:

0

Hi, I create a .net custom usercontrol to be used in COM through Borland C++ Builder.

1) i implement an explicit interface and decorate it with some attributes (ComVisibleAttribute, GuidAttribute and InterfaceTypeAttribute). This interface has 3 properties just to try, each property has a DispIdAttribute.

`namespace SimpleCOMServer{
[ComVisible( true )]
[Guid( "FE5825B8-6989-4e81-9018-E0403FD3F85E" )]
[InterfaceType( ComInterfaceType.InterfaceIsIDispatch )]
public interface IMyUserControl`
{
    [DispId(1)]
    string LABEL{get; set;}

    [DispId( 2 )]
    string TEXTBOX{get; set;}

    [DispId( 3 )]
    string BUTTON_TEXT{get; set;}
}

}

2) The class MyUserControl implements this interface and extends UserControl .net base class. This class is also decorated with some attributes

namespace SimpleCOMServer{
[Guid( "969BF567-6C9E-4c9f-813B-F174563D840D" )]
[ClassInterface( ClassInterfaceType.None ), ComVisible(true)]
[ProgId( "SimpleCOMServer.MyUserControl" )]
public partial class MyUserControl : UserControl, IMyUserControl
{
    public MyUserControl()
    {
        InitializeComponent();
    }

    [ComVisible(true)]
    public string LABEL
    {
        get
        {
            return this.label1.Text;
        }
        set
        {
            this.label1.Text = value;
        }
    }

    [ComVisible( true )]
    public string TEXTBOX
    {
        get
        {
            return this.textBox1.Text;
        }

        set
        {
            this.textBox1.Text = value;
        }
    }

    [ComVisible( true )]
    public string BUTTON_TEXT
    {
        get
        {
            return this.button1.Text;
        }
        set
        {
            this.button1.Text = value;
        }
    }
}

}

3) I compile & sign the assembly and test it; it works very well under .net.

4) I move to a virtual machine where i installed Borland C++ Builder and .net client profile.

5) I add the assembly to GAC, i register this assembly and i export type library through regasm tool

6) Within Borland, i import the type libray (Project -> Import Type Library...) and i load the type library exported with regasm; a package is generated and the component is added in the sample tab. I also check registry system and every is ok.

Here is the problem: if i drag & drop this component, no usercontrol is drawn but i can call all property implemented. I don't know what's wrong. Plz help