3

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.

Pavel Podlipensky
  • 8,201
  • 5
  • 42
  • 53

2 Answers2

4

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
  • 1,023,142
  • 271
  • 3,287
  • 2,928
  • I was recently looking for `IDispatchEx` interop definition and wrapper for C# and couldn't find any, the link in this answer appears to have gone. So I had to create it from scratch, [here it is](http://stackoverflow.com/a/18546866/1768303) in case someone may need it. – noseratio Sep 02 '13 at 09:43
0

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
  • 1,026,079
  • 266
  • 2,566
  • 2,900
  • 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. – Pavel Podlipensky Mar 15 '09 at 10:00
  • 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. – Pavel Podlipensky Mar 15 '09 at 10:02