views:

54

answers:

1

Hi,

it looks like that I am not able to expose via COM a class to an unmanaged client if one of the property of the class has type DateTime .

Example:

[ComVisible(true)]
public interface ITest
{
   string Name { get; }
   DateTime Date { get; }
}

[Serializable]
[ComVisible(true)]
public class Test : ITest
{
    public string Name { get; private set; }
    public DateTime Date { get; private set; }
}

Only if I comment out the Date property on both the interface and implementation will the .tlh file contain a the Test structure (obviously without the Date).

Any idea? Is there a way to represent a date that is visible via COM? Do I really need to pass the Date as a string and then parse it?

Thank you for your time!

+1  A: 

In COM, a Date is a Variant of type VT_DATE. I think you can make use of this: http://blogs.msdn.com/dimeby8/archive/2006/12/12/marshalling-variant-properties-in-c.aspx

danbystrom