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>lanserverhaimDellDocVisual Studio BARDApp12nReviewer.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>lanserverhaimDellDocBARDApp12nSRRemindDialog.vb(620,9): warning CA1416: …
6>lanserverhaimDellDocBARDApp12nReviewer.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?
2
Answers
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:
I changed the "&" to "+" and then it compiled. Strangely, I could also fix the error this way:
intresp = MessageBox.Show(ermsg, "Warning", MessageBoxButtons.YesNo)
I could use the & to concatenate the strings when defining a string, but it would not accept it inside the call to MessageBox.Show().
.NET 8 is designed to be cross-platform, while .NET Framework is Windows-specific.
Since
MessageBox.Show
is a Windows Forms method, it’s specific to Windows. To ensure compatibility, you might need to wrap it in a conditional compilation block if your application needs to support multiple platforms.If you only intend to use this application on Windows, you can set Target OS to Windows in Project Properties for the project which will fix the warning.