开发者

Marshal generic return types for com interop

Is it possible to Marshal a generic return type as non-generic for COM interop?

Let's say I have the following class:

[ComVisible(true)]
public class Foo
{
    public IEnumerable<string> GetStr() // Generic return开发者_开发百科 type
    {
        yield break;
    }
}

I know that IEnumerable<string> implements IEnumerable.

Can I force tlbexp.exe (via return: attribute or via some other way) to expose GetStr() method as a method returning IEnumerable?


I don't think that's possible, no. When you hit limitations with COM interop marshaling, it's usually better to create a separate wrapper type with a COM friendly interface, and leave the original type as .NET friendly as possible.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜