Thanks for your response and interest - I need the help. My mistake, it's
actually a link problem (i.e., not compile); the link errors are as follows:
Interface Assembly Link Errors:
MyInterface.obj : error LNK2020: unresolved token (0600003A)
IMyInterface::add_OnEventPost
MyInterface.obj : error LNK2020: unresolved token (0600003B)
IMyInterface::remove_OnEventPost
Implementing Ref Class Assembly Link Errors:
MyClass.obj : error LNK2020: unresolved token (0600003A)
IMyInterface::add_OnEventPost
MyClass.obj : error LNK2020: unresolved token (0600003B)
IMyInterface::remove_OnEventPost
Note the interface is in one assembly while implementing class is in another
assembly (as encouraged by interface programming guidance) thus the 2 sets of
link errors. Again this approach seems to work fine for all normal methods
and only has problems (i.e., link errors) dealing with events.
In reviewing these errors since our initial exchange, it's like I need to
define other 'stuff' just because I've now published in the interface. But
what other stuff (e.g., add, remove, raise) and what should it look like?
Again keep in mind all works fine if I use in VB directly refed as class
instead of interface.
I have tried eliminating the const specifier with no material change in
result.
Again thanks for any guidance here
[quoted text, click to view] "Ben Voigt" wrote:
>
> > In the example below as coded, in a VB app I can access and use the
> > general
> > method (MyMethod) if I declare my handle variable as an IMyInterface type.
> > I
> > can also use the general method and handle the event in VB if I declare as
> > a
> > CMyClass. I cannot however seem to expose the static event through the
> > interface IMyInterface; any ideas?
>
> Should work according to:
> "An interface can contain declarations for functions, events, and
> properties. All interface members have public accessibility. An interface
> can also contain static data members, functions, events, and properties, and
> these static members must be defined in the interface."
>
> Note "must be defined in the interface", this probably prohibits forward
> declaration.
>
> >
> > public interface class IMyInterface
> > {
> > void MyMethod();
> >
> > // delegate void EventHandler(const long lVal, bool% bVal); - WONT
> > COMPILE
>
> Have you tried without the const? Essentially const is only supported in
> unmanaged code, managed types can only use literal and initonly, neither or
> which are the same as const and neither of which can be applied to an
> argument.
>
> > // static event EventHandler^ OnEventPost; - WONT COMPILE
> > };
>
> What's the exact error message?
>
>