VB Anonymous Delegate

StewartBW 1,905 Reputation points
2025-06-09T14:02:01.5733333+00:00

Hi

My app has a new item when seen in IL DASM: VB$AnonymousDelegate_0

The older builds didn't have this; how can I find which code caused this entry to be added inside assembly that is shown in IL DASM?

Thanks :)

Developer technologies | VB
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Susmitha T (INFOSYS LIMITED) 1,630 Reputation points Microsoft External Staff
    2025-11-13T15:23:04.21+00:00

    Thanks for reaching out!

     
    You have encountered an anonymous delegate in your assembly that was not present in the previous builds of your app. This could be due to a few different reasons, often linked to the use of Lambda expressions or AddressOf references that are not directly associated with named methods.

    Here are some steps you can take to identify the code that introduced the VB$AnonymousDelegate_0 entry:

    1. Check for Lambda Expressions: Look through your code for any Lambda expressions that might be creating delegates. For example, if you are using LINQ or event handling, this might result in an anonymous delegate being generated.
    2. Inspect Delegate Usage: Search for instances where you might be using the AddressOf operator, as this can also generate anonymous delegates if the method referred to is not named.
    3. Look into Event Handling: If you're implementing event handlers using AddHandler, review those sections of code to see if any anonymous methods are being created.
    4. Review Recent Changes: Compare your current code with older versions to spot recent additions or changes that could involve delegate usage.

    References: https://learn.microsoft.com/en-us/dotnet/visual-basic/programming-guide/language-features/delegates/
    https://learn.microsoft.com/en-us/dotnet/visual-basic/programming-guide/language-features/delegates/
    https://learn.microsoft.com/en-us/dotnet/visual-basic/programming-guide/concepts/object-oriented-programming

    Let me know if you need any further help with this. I will be happy to assist.

     If you find this helpful, Kindly mark the provided solution as "Accept Answer", so that others in the community facing similar issues can easily find the solution. Your contribution is highly appreciated.


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.