SharpDevelop “invalid EventMemberSpecifier” Error & Solution

The Problem

SharpDevelop, for those of you that haven’t heard of it, is a very light-weight open source alternative to Visual Studio 2005. It doesn’t have all the frills and features that Microsoft’s professional IDE does, but in exchange it gives you much less bloat, faster speeds, and quite a few nifty built-in tools like SVN integration, FxCop auto-checking, code profiling, language conversion (C# <-> VB.NET <-> Boo#), and a bit more – but it has its drawbacks, too.

SharpDevelop is intended to be a 100% open source drop-in replacement for the Visual Studio IDE on Windows (there’s MonoDevelop for Linux if you like), and for the most part, it works just fine. But once in a while, an odd quirk pops up that’s rather obvious & common… yet unsolved and makes us wonder.

Anyway, if you’re getting any errors like:

Syntax errors in Form1.vb:
-- line 8900 col 121: invalid EventMemberSpecifier

Then you are suffering from such an oversight. It turns out that Visual Studio 2005 uses “Handles Me.xxxxx” to assign event handlers to form components in Visual Basic 2005. Now it’s not very clear what exactly is “right” per-say here, but SharpDevelop doesn’t recognize this as valid code, and instead requires “Handles MyBase.xxxxx” appended to functions that handle form components.

The Solution

When you access the “Designer” tab you’ll be presented with the message above. To fix it, simply switch to the code-behind display by selecting the appropriate tab at the bottom, then press “ctrl+f” to search for code. Switch to the “replace” tab, and type in: Handles Me. and in the “replace” section enter Handles MyBase. and click “replace all.”

Luckily Visual Studio 2005 is compatible with both “MyBase” and “Me” when referring to the parent form in Visual Basic 2005, so with this simple change you should be able to freely switch back and forth between the two without much trouble.

  • Similar Posts

    Craving more? Here are some posts a vector similarity search turns up as being relevant or similar from our catalog you might also enjoy.
    1. The Un-Improvements to “Find All References” in Visual Studio 2010
  • 5 thoughts on “SharpDevelop “invalid EventMemberSpecifier” Error & Solution

    1. Thanks for the heads-up, Daniel. I’m glad to hear it’s been patched since SharpDevelop used to also not recognize existing handles for .NET form components in VB.NET (basically Private/Public Sub xxx() Handles yyyyy) and would add new event handlers for everything.

    2. I confused this with another VB parser bug; this bug is already fixed since revision 2437, so the fix is included in the SharpDevelop release.

      Only the VB parser was fixed, the forms designer still doesn’t support Handles clauses.

    Leave a Reply

    Your email address will not be published. Required fields are marked *