none
How to generate interop methods instead of properties? RRS feed

  • Question

  • Hi

    I wonder if there is a way to make tlbimp.exe to generate methods instead of properties when a CoClass is involved, or as a general default if the CoClass-check cannont be done.

    I want:

    CoClassDepartment GetDepartment();

    void SetDepartment(CoClassDepartment department);

    Instead of:

    CoClassDepartment Department { get; set; } 

    This is because I have problem setting a COM pointer reference on an another COM pointer reference that is a CoClass. 

    Eg:

    MyComObjectInterfacePointer.PropertyasCoClass = (CoClassCast)AnotherComObjectInterfacePointer;

    I have to do a cast here to avoid compilation error. At runtime no exceptions are thrown but I'm not able to set the property either. The metadata says there is a set and get for det property but it wont be set.

    Hope someone understand what I'm trying to describe here. I guess there is two solutions:

    1) Make the tlbimp.exe generate methods instead of properties

    2) There is some method in the .NET Framework that gives me the CoClass in a manner that is required, I'm not sure what this is.... anyone?

    Thanks in advance!


    • Edited by NorwegianEcho Wednesday, July 13, 2011 9:25 AM Additional information and some text formatting
    Wednesday, July 13, 2011 9:03 AM

Answers