views:

184

answers:

1

ETA: I use visual studio 2008 express edition.

If I override WndProc and mess up somehow, I'll usually backtrack by commenting out code until it works again.

The strange thing with WndProc though is you can strip it down to:

Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
    MyBase.WndProc((m))
End Sub

and it still throws the error.

I have to remove the code and retype it in to reset the error.

Anyone else experienced this?

ETA:

Answered below by Chris Haas.

I hadn't realised, but this problem must only have occurred when I'd used code from reflector. Reflector mis-translates to vb.net and inserts extra brackets into the calls to WndProc base.

+4  A: 

When you wrap an argument in parenthesis you are overriding the ByRef call and instead calling it ByVal. See Argument Not Being Modified by Procedure Call - Underlying Variable

Just change the code to:

Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
    MyBase.WndProc(m)
End Sub
Chris Haas
Cheers, looks like that is it. The code I was starting with was from reflector which is mistranslating to vb.net and inserting the brackets when they shouldn't be there. Mystery solved!
Jules