Search code examples
vb.netvisual-studiowinforms.net-coremigration

VBC Error '& e_emb.Message Visual Studio 22 Preview


I am trying to upgrade a vintage vb winform app to from framework 4.72 to .NET 8. I am using visual studio 2022 preview (latest version). I have reduced the number of errors I get in the build process from over 9000 to 1. This seems to be the most difficult one to solve. In the error window I get this message:

Error (active) " & e_emb.Message) File: vbc Line 1

In my output window, amidst a sea of warnings the error appears as follows:

6>\lanserver\haim\DellDoc\Visual Studio \BARDApp12n\Reviewer.vb(3821,13): warning CA1416: This call site is reachable on all platforms. ... 6>VBC : MessageBox.Show("The Message was not sent do to the following error : " & e_emb.Message) 6>\lanserver\haim\DellDoc\BARDApp12n\SRRemindDialog.vb(620,9): warning CA1416: ... 6>\lanserver\haim\DellDoc\BARDApp12n\Reviewer.vb(3814,21): warning CA1416: ...

While the output messages don't appear to be in any particular order, I do eliminate the error if I exclude the reviewer.vb (a winform) from the project. My strategy now is to comment out portions of the code on that form until I find the culprit. I couldn't find this specific problem on the web. Does anyone have an idea where I can find the error?


Solution

  • Thank you @jmcihinney. Its always good to have another set of eyes look at the code. I didn't notice that the output referred to the line MessageBox.Show. The code in the error message box was somewhat cryptic. The actual code is as follows:

    MessageBox.Show("This reviewer has been sent a request." & vbCr & "Do you want to continue?", "Warning", MessageBoxButtons.YesNo)
    

    I created the string outside the function call. Strangely, I could also fix the error this way:

    Dim ermsg = "This reviewer has been sent a request." & vbCr & "Do you want to continue?"
    intresp = MessageBox.Show(ermsg, "Warning", MessageBoxButtons.YesNo)
    

    Using & or '+' to concatenate the strings didn't make a difference, but it would not accept either inside the call to MessageBox.Show().