tags:

views:

197

answers:

2

Hi,

Can't find the library which contains IDispatchEx interface. I want to implement this interface, but can't find it. Does anyone knows where it is?

Thanks, Paul.

A: 

What exactly do you want to do? Is this for use inside C#? Or from outside (COM)?

If you just want browser support, then perhaps host in WebBrowser and set the ObjectForScripting.

You can sort of add methods to a type in C# 3.0 with extension methods:

public static void Bar(this Foo foo, int someArg) {...}
....
Foo foo = ...
foo.Bar(123);

But this is still static-typed. C# 4.0 introduces dynamic for true dynamic objects inside the CLR/DLR, but you'd implement IDynamicObject. And it isn't trivial.

Marc Gravell
Thanks! But I want to emulate unexisted property(or method) in my C# class when its called from javascript. For example,var o=new ActiveXObject('object');o.Foo("hi");Please note that Foo method doesnt exists in my C# class. So I want to impelement IExpando.AddMethod to achieve my goal.
Paul Podlipensky
But with IExpando.AddMethod I have some troubles - it doesn't invokes when unexisted method called. But it works well when unexisted field called (I mean IExpando.AddField fired). So I can't figure the difference and want to try IDispatchEx interface.
Paul Podlipensky
+2  A: 

If you want to write a managed class that implements the IDispatchEx interface you will first need to define this interface because it does not exist in .NET. Here's a link to its definition. IMHO implementing this interface won't be a trivial task.

Darin Dimitrov