c# property exposed as COM bindable property

Discussion in 'Microsoft C# .NET' started by Miguel.Herrera@visy.com.au, Oct 12, 2005.

  1. Guest

    I like to create an assembly with a property exposed in COM as
    bindable. I have tried to use [Bindable(true)] attribute but when I
    check the typelib produced by regasm for my assembly the property does
    not have bindable on it.

    Here is some code of what I mean:

    [Bindable(true)]
    public bool ActiveXDone
    {
    get
    {
    return _activeXDone;
    }
    set
    {
    _activeXDone = value;
    }
    }

    when I use regasm to generate a typelib for my assembly I like to get
    the following (note the bindable attribute):

    [id(0x60020000), propget, bindable]
    HRESULT ActiveXDone([out, retval] VARIANT_BOOL* pRetVal);
    [id(0x60020000), propput, bindable]
    HRESULT ActiveXDone([in] VARIANT_BOOL pRetVal);

    but instead I get the following :

    [id(0x60020000), propget]
    HRESULT ActiveXDone([out, retval] VARIANT_BOOL* pRetVal);
    [id(0x60020000), propput]
    HRESULT ActiveXDone([in] VARIANT_BOOL pRetVal);


    What am I doing wrong ?
     
    , Oct 12, 2005
    #1
    1. Advertisements

  2. Hi Miguel!

    The [Bindable] attribute is for managed design-time environment, as far as I
    know it has no effect on COM-visible type libraries.
    I have looked through all System.Runtime.InteropServices attributes and it
    seems there is no suitable attribute at all :-(.

    Re-posting your question in microsoft.public.dotnet.framework.interop might
    give better results.

    --
    Sincerely,
    Dmytro Lapshyn [Visual Developer - Visual C# MVP]


    <> wrote in message
    news:...
    >I like to create an assembly with a property exposed in COM as
    > bindable. I have tried to use [Bindable(true)] attribute but when I
    > check the typelib produced by regasm for my assembly the property does
    > not have bindable on it.
    >
    > Here is some code of what I mean:
    >
    > [Bindable(true)]
    > public bool ActiveXDone
    > {
    > get
    > {
    > return _activeXDone;
    > }
    > set
    > {
    > _activeXDone = value;
    > }
    > }
    >
    > when I use regasm to generate a typelib for my assembly I like to get
    > the following (note the bindable attribute):
    >
    > [id(0x60020000), propget, bindable]
    > HRESULT ActiveXDone([out, retval] VARIANT_BOOL* pRetVal);
    > [id(0x60020000), propput, bindable]
    > HRESULT ActiveXDone([in] VARIANT_BOOL pRetVal);
    >
    > but instead I get the following :
    >
    > [id(0x60020000), propget]
    > HRESULT ActiveXDone([out, retval] VARIANT_BOOL* pRetVal);
    > [id(0x60020000), propput]
    > HRESULT ActiveXDone([in] VARIANT_BOOL pRetVal);
    >
    >
    > What am I doing wrong ?
    >
     
    Dmytro Lapshyn [MVP], Oct 12, 2005
    #2
    1. Advertisements

  3. Miguel,

    You might have to reverse engineer some of the generated code to do
    this. Offhand, I would create the TLB file, and then use OLEVIEW to view
    the IDL.

    Then, I would copy and paste the IDL into a new file, and add the
    bindable attribute to the idl in the appropriate places. Once that is done,
    I would run that IDL file through MIDL, and create a type library. Once you
    do that, you should be able to register that type library to create your
    CCW's.

    Hope this helps.


    --
    - Nicholas Paldino [.NET/C# MVP]
    -

    <> wrote in message
    news:...
    >I like to create an assembly with a property exposed in COM as
    > bindable. I have tried to use [Bindable(true)] attribute but when I
    > check the typelib produced by regasm for my assembly the property does
    > not have bindable on it.
    >
    > Here is some code of what I mean:
    >
    > [Bindable(true)]
    > public bool ActiveXDone
    > {
    > get
    > {
    > return _activeXDone;
    > }
    > set
    > {
    > _activeXDone = value;
    > }
    > }
    >
    > when I use regasm to generate a typelib for my assembly I like to get
    > the following (note the bindable attribute):
    >
    > [id(0x60020000), propget, bindable]
    > HRESULT ActiveXDone([out, retval] VARIANT_BOOL* pRetVal);
    > [id(0x60020000), propput, bindable]
    > HRESULT ActiveXDone([in] VARIANT_BOOL pRetVal);
    >
    > but instead I get the following :
    >
    > [id(0x60020000), propget]
    > HRESULT ActiveXDone([out, retval] VARIANT_BOOL* pRetVal);
    > [id(0x60020000), propput]
    > HRESULT ActiveXDone([in] VARIANT_BOOL pRetVal);
    >
    >
    > What am I doing wrong ?
    >
     
    Nicholas Paldino [.NET/C# MVP], Oct 12, 2005
    #3
  4. Nicholas,

    I must say "live and learn" - I did not know before that one could create a
    CCW from an already existing type library. Is there an example? What I
    personally would try is creating a type library containing interfaces only,
    then I'd run tlbimp.exe on it and create my [ComVisible] classes that
    implement interfaces imported from the type library.

    --
    Sincerely,
    Dmytro Lapshyn [Visual Developer - Visual C# MVP]


    "Nicholas Paldino [.NET/C# MVP]" <> wrote in
    message news:...
    > Miguel,
    >
    > You might have to reverse engineer some of the generated code to do
    > this. Offhand, I would create the TLB file, and then use OLEVIEW to view
    > the IDL.
    >
    > Then, I would copy and paste the IDL into a new file, and add the
    > bindable attribute to the idl in the appropriate places. Once that is
    > done, I would run that IDL file through MIDL, and create a type library.
    > Once you do that, you should be able to register that type library to
    > create your CCW's.
    >
    > Hope this helps.
    >
    >
    > --
    > - Nicholas Paldino [.NET/C# MVP]
    > -
    >
    > <> wrote in message
    > news:...
    >>I like to create an assembly with a property exposed in COM as
    >> bindable. I have tried to use [Bindable(true)] attribute but when I
    >> check the typelib produced by regasm for my assembly the property does
    >> not have bindable on it.
    >>
    >> Here is some code of what I mean:
    >>
    >> [Bindable(true)]
    >> public bool ActiveXDone
    >> {
    >> get
    >> {
    >> return _activeXDone;
    >> }
    >> set
    >> {
    >> _activeXDone = value;
    >> }
    >> }
    >>
    >> when I use regasm to generate a typelib for my assembly I like to get
    >> the following (note the bindable attribute):
    >>
    >> [id(0x60020000), propget, bindable]
    >> HRESULT ActiveXDone([out, retval] VARIANT_BOOL* pRetVal);
    >> [id(0x60020000), propput, bindable]
    >> HRESULT ActiveXDone([in] VARIANT_BOOL pRetVal);
    >>
    >> but instead I get the following :
    >>
    >> [id(0x60020000), propget]
    >> HRESULT ActiveXDone([out, retval] VARIANT_BOOL* pRetVal);
    >> [id(0x60020000), propput]
    >> HRESULT ActiveXDone([in] VARIANT_BOOL pRetVal);
    >>
    >>
    >> What am I doing wrong ?
    >>

    >
    >
     
    Dmytro Lapshyn [MVP], Oct 13, 2005
    #4
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Marc Scheuner [MVP ADSI]

    Making a business objects collection grid-bindable

    Marc Scheuner [MVP ADSI], Apr 22, 2004, in forum: Microsoft C# .NET
    Replies:
    2
    Views:
    255
    Marc Scheuner [MVP ADSI]
    Apr 26, 2004
  2. Andrew Hayes

    Adding a Bindable Property to an Web User Control

    Andrew Hayes, Nov 20, 2006, in forum: Microsoft C# .NET
    Replies:
    0
    Views:
    489
    Andrew Hayes
    Nov 20, 2006
  3. tombow
    Replies:
    0
    Views:
    359
    tombow
    Apr 25, 2007
  4. Steve K.
    Replies:
    2
    Views:
    266
    sklett
    Jan 22, 2008
  5. Alcibiade

    looking for a datetime picker bindable and nullable

    Alcibiade, Sep 30, 2010, in forum: Microsoft C# .NET
    Replies:
    0
    Views:
    277
    Alcibiade
    Sep 30, 2010
Loading...

Share This Page