Extension Methods in VB 2008 Express?

G

Guest

I can't get Extension Methods to work in Visual Basic 2008 Express.

Says "Type 'Extension' is not defined."

Looks like the library included with the Express edition is crippled.

What am I missing?

Here's the code...
Imports System.Runtime.CompilerServices
Module ExtensionMethods
<Extension()> Public Function Test(ByVal str As String) As String
Return str
End Function
End Module
 
A

Armin Zingler

dave said:
I can't get Extension Methods to work in Visual Basic 2008 Express.

Says "Type 'Extension' is not defined."

Looks like the library included with the Express edition is
crippled.

What am I missing?

Here's the code...
Imports System.Runtime.CompilerServices
Module ExtensionMethods
<Extension()> Public Function Test(ByVal str As String) As String
Return str
End Function
End Module

Add a reference to System.Core.dll


Armin
 
R

Rory Becker

I can't get Extension Methods to work in Visual Basic 2008 Express.
Says "Type 'Extension' is not defined."

Looks like the library included with the Express edition is crippled.

What am I missing?

Here's the code...
Imports System.Runtime.CompilerServices
Module ExtensionMethods
<Extension()> Public Function Test(ByVal str As String) As String
Return str
End Function
End Module

Are you targetting .Net 2.0, see my blog posts....
Where I thought it was a bug....
 
R

Rory Becker

Alternatively you might not have added a reference to System.Core.dll to
your .Net 3.5 project
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top