Skip to content
This repository has been archived by the owner on Nov 3, 2023. It is now read-only.

Vb compiler creates invalid assembly if contains Events in special form #37

Open
rolfbjarne opened this issue May 22, 2018 · 0 comments

Comments

@rolfbjarne
Copy link
Member

rolfbjarne commented May 22, 2018

Submitted by a community member on 2015-08-14 17:32 UTC

If in sources used event in form:

Event Evt As <DelegateType>

Then method that raise such event produce incorrect IL (that could not be loaded by any tools).

Please try sample:

rem//@generateExecutable
Imports System

Public Module Program
    Public Sub Main(ByVal Args As String())
        Dim instance As CustomType = New CustomType()
        instance.FireEvent()
    End Sub
End Module

Public Class CustomType
    Public Event Evt As Action(Of Integer)

    Public Sub FireEvent()
        RaiseEvent Evt(1)
    End Sub
End Class

Steps to reproduce:

  1. Compile sample code
  2. Execute it

Expected result:
Program finish correctly

Actual result:
On Mono:

Unhandled Exception:
System.TypeLoadException: A type load exception has occurred.
  at Program.Main (System.String[] Args) [0x00000] in <filename unknown>:0

[ERROR] FATAL UNHANDLED EXCEPTION: System.TypeLoadException: A type load exception has occurred.
  at Program.Main (System.String[] Args) [0x00000] in <filename unknown>:0

On .Net:

Unhandled Exception: System.BadImageFormatException: An attempt was made to load a program with an incorrect format. (Exception from HRESULT: 0x8007000B)
   at CustomType.FireEvent()
   at Program.Main(String[] Args)

Reference: https://bugzilla.xamarin.com/show_bug.cgi?id=33118

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant