VB.net: Suppress Error Message Problem
I have read the MSDN开发者_如何学Go Page on how to suppress messages. I am unable to supress warnings for VS2008.
I have tried the following instructions listed:
In the Error List, select the warning or warnings to suppress. Multiple warnings can be selected at the same time.
Right-click the warning, point to Suppress Message(s), and click either In Source or In Project Suppression File.
The specific warning is suppressed, and the warning appears in the Error List window with a strikethrough.
However, when I right click in the 'Error List' I only get the following options:
- Sort By
- Show Columns
- Show Error Help
- Copy
- Previous Error
- Next Error
Why does Visual Studios 2008 for VB.net not display 'Suppress Messages'?
I cannot generate the following suppressing messages:
<Scope:SuppressMessage("Rule Category", "Rule Id", "Justification", "MessageId", Scope = "Scope", Target = "Target")>
The problem was I had a series of parallel tasks that were dependent on check boxes. I wanted each task to to run simultaneously and then join back. I overcame the warning by using a callback method that decremented until all the call backs completed.
ie (from memory):
chkbox1.enable = false
chkbox2.enable = false
dim dlgChkbox1 as Action = addressof Task1
dim dlgChkbox2 as Action = addressof Task2
...
if chkbox1.checked = true then
result = dlgChkbox1.BeginInvoke(nothing,nothing)
end if
if chkbox2.checked = true then
result = dlgChkbox2.BeginInvoke(nothing,nothing)
end if
...
if chkbox1.checked = true then
dlgChkbox1.EndInvoke()
end if
if chkbox1.checked = true then
dlgChkbox2.EndInvoke()
end if
...
chkBox1.enable = true
chkBox2.enable = true
The warning was an Uninitialized Variable. Which was not the case as it was dependent on identical if-statements. I opted to use a callback method instead, which turned out to be a better alternative and did not lock up the GUI.
Wrong MSDN page. That one talks about suppressing warnings produced by the Code Analysis tool. Very different animal from the VB.NET compiler.
To suppress compiler warnings, use Project + Properties, Compile tab, Warning configurations section. Locate the specific warning message you want to disable, change the notification setting from "Warning" to "None". The "Disable all warnings" checkbox is the big hammer solution.
精彩评论