ETA:我使用visual studio 2008 express edition。
如果我覆盖WndProc并以某种方式陷入困境,我通常会通过评论代码来回溯,直到它再次起作用。
WndProc的奇怪之处在于你可以把它剥离到:
Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
MyBase.WndProc((m))
End Sub
它仍然会抛出错误。
我必须删除代码并重新键入以重置错误。
其他人经历过这个?
ETA:
Chris Haas在下面回答。
我没有意识到,但只有在我使用反射器代码时才会出现这个问题。 Reflector错误地转换为vb.net并在对WndProc base的调用中插入额外的括号。
答案 0 :(得分:4)
当您在括号中包装参数时,您将覆盖ByRef
调用,而是将其称为ByVal
。见Argument Not Being Modified by Procedure Call - Underlying Variable
只需将代码更改为:
Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
MyBase.WndProc(m)
End Sub