In VS2022, VB hot reload never works, claiming ENC0005, when Handles is not relevant

peter rumsey 20 Reputation points
2025-03-07T05:07:54.19+00:00

In this code, deleting either LstLog line text while at the breakpoint evinces the problem. You can use Debug. instead of LstLog.

    Private Sub mnuLogShown_Click(sender As Object, e As EventArgs) Handles mnuLogShown.Click
        LstLog.Write($"--------> File Pair List started at {Now}")
        LstLog.Write($"{fPair.LName}|#{xPair}|{fPair.RName}")
        For Each i In fPair.Map
            Dim item = cFiles(i).lvItem
            If Not item.fPair.Op.Any(Op.Ops) Then Continue For
            'LstLog.Write()
            Debug.WriteLine($"{item.LText} {item.Ops} {item.RText}")
        Next i '<--breakpoint>
    End Sub

Developer technologies | Visual Studio | Debugging
{count} votes

Accepted answer
  1. Tianyu Sun-MSFT 34,456 Reputation points Microsoft External Staff
    2025-03-19T13:03:20.8033333+00:00

    Hi @peter rumsey ,

    Thank you very much for sharing the sample project.

    I can reproduce this issue.

    I notice that the hot reload issue you got is impacted by the configuration for AssemblyVersion property.

    In AssemblyInfo.vb file, it was set to <Assembly:AssemblyVersion("2.0.*")>(with <Deterministic> property set to false, in the .vbproj file).

    User's image

    User's image

    By the way, the AssemblyVersion property can be set/checked by right-clicking the project > Properties > Application > Assembly Information > Assembly version.

    User's image

    After researching and analyzing, I doubt that this is a potential issue. I suggest you submit a ticket on our Developer Community(in VS, click Help > Send Feedback > Report a Problem) and direct report this issue to Visual Studio Product Team.

    Currently, if you want to mitigate this issue, you can set and use a specific assembly version, instead of using wildcard *.

    For example, changing 2.0.* to 2.0.0.0.

    User's image

    User's image


    Update1:

    Above is the direct cause, not the root cause.

    Further tests show that even using .NET 9 projects, this issue persists.

    As the error message shows very specific, I have reported this issue.

    Here's the ticket link: The VB WinForm project shows ENC0005 error while debugging in VS 2022 and using hot reload. Kindly try to follow that ticket and wait for the latest information.

    By the way, the "Restart Application" option is a little quicker for restarting the application in this situation.

    User's image

    Kind regards,

    Tianyu


    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


0 additional answers

Sort by: Most helpful

Your answer

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