Major bug with Interface Events and Shared Events 
Author Message
 Major bug with Interface Events and Shared Events

There is a major bug with either the VB compiler or the class Loader
in the VM.

If an interface has an event defined and a concrete class implements
that interface as a shared event, then the loader will throw the
following exception:

System.TypeLoadException: Body referenced in a method implementation
can not be static.  Type: myTestApp.testClass2.  Assembly: myTestApp,
Version=1.0.1249.22558, Culture=neutral, PublicKeyToken=null.

The following code shows the problem (simply remove the commented code
to cause the error).

Only testClass2 has a problem. It seems that you can have a shared
event in a class and an interface event in a class, just *NOT* a
shared interface event in a class.

Public Interface testInterface
    Event testEvent()
End Interface
Public Class testClass
    Public Shared Event test()
End Class
Public Class testClass2
    Implements testInterface
    Public Shared Event test() Implements testInterface.testEvent
End Class
Public Class testClass3
    Implements testInterface
    Public Event test() Implements testInterface.testEvent
End Class
Public Class frmConfig
    Inherits System.Windows.Forms.Form
    Private Debugging As Boolean = False
    Private guiConfig As New XmlDocument()
    Private testobj As New testClass()
    Private testobj2 As New testClass2()
    Private testobj3 As New testClass2()
End Class



Tue, 22 Nov 2005 05:20:18 GMT  
 Major bug with Interface Events and Shared Events
Hi, Of course you can't because the interface didn't define the event as
shared :-)

--
Happy to help,
-- Tom Spink

Please respond to the newsgroup,
so all can benefit.

One Day,

Quote:
> There is a major bug with either the VB compiler or the class Loader
> in the VM.

> If an interface has an event defined and a concrete class implements
> that interface as a shared event, then the loader will throw the
> following exception:

> System.TypeLoadException: Body referenced in a method implementation
> can not be static.  Type: myTestApp.testClass2.  Assembly: myTestApp,
> Version=1.0.1249.22558, Culture=neutral, PublicKeyToken=null.

> The following code shows the problem (simply remove the commented code
> to cause the error).

> Only testClass2 has a problem. It seems that you can have a shared
> event in a class and an interface event in a class, just *NOT* a
> shared interface event in a class.

> Public Interface testInterface
>     Event testEvent()
> End Interface
> Public Class testClass
>     Public Shared Event test()
> End Class
> Public Class testClass2
>     Implements testInterface
>     Public Shared Event test() Implements testInterface.testEvent
> End Class
> Public Class testClass3
>     Implements testInterface
>     Public Event test() Implements testInterface.testEvent
> End Class
> Public Class frmConfig
>     Inherits System.Windows.Forms.Form
>     Private Debugging As Boolean = False
>     Private guiConfig As New XmlDocument()
>     Private testobj As New testClass()
>     Private testobj2 As New testClass2()
>     Private testobj3 As New testClass2()
> End Class



Tue, 22 Nov 2005 05:35:30 GMT  
 Major bug with Interface Events and Shared Events
Charles,

Which version of the compiler are you using? The VS.NET 2003 /
framework v1.1 compiler gives a compile error

error BC30505: Methods or events that implement interface members
cannot be declared 'Shared'.

    Public Shared Event test() Implements testInterface.testEvent

Mattias

===

http://www.msjogren.net/dotnet/
Please reply only to the newsgroup.



Tue, 22 Nov 2005 05:35:54 GMT  
 Major bug with Interface Events and Shared Events
Hello Mattias,


Quote:
> Which version of the compiler are you using? The VS.NET 2003 /
> framework v1.1 compiler gives a compile error

> error BC30505: Methods or events that implement interface members
> cannot be declared 'Shared'.

That's interesting. When compiling with VS .NET 2003 (Fx 1.0) there is
no error.

Regards,
Herfried K. Wagner
--
http://www.mvps.org/dotnet



Tue, 22 Nov 2005 06:08:17 GMT  
 Major bug with Interface Events and Shared Events
Herfried,

Quote:
>That's interesting. When compiling with VS .NET 2003 (Fx 1.0) there is
>no error.

I assume you mean VS.NET 2002? I guess that means they fixed the bug.
A good thing!

Mattias

===

http://www.msjogren.net/dotnet/
Please reply only to the newsgroup.



Wed, 23 Nov 2005 21:35:11 GMT  
 Major bug with Interface Events and Shared Events
Hello Mattias,


Quote:
> >That's interesting. When compiling with VS .NET 2003 (Fx 1.0) there is
> >no error.

> I assume you mean VS.NET 2002? I guess that means they fixed the bug.
> A good thing!

Ooops. Typo. I used VS .NET 2002.

;-)

Regards,
Herfried K. Wagner
--
http://www.mvps.org/dotnet



Wed, 23 Nov 2005 21:41:42 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. : Sharing events between interfaces

2. Events, Events, alas, wherefore art thou events...

3. Events, Events, alas, wherefore art thou events...

4. Events, Events, alas, wherefore art thou events...

5. Control Event Problem (Post Event after an event is fired)

6. ItemRemove event from a shared / public folder

7. Need help understanding sinking events thru interface

8. need help with shared events

9. Implementing Interface Events...

10. Interfaces Events and the System.TypeLoadException error.

11. Interfaces Event and sytem.TypeLoadException error

12. Shared events

 

 
Powered by phpBB® Forum Software