views:

963

answers:

2

I'm using the latest release of IKVM to "compile" a Java .jar file into a .NET DLL. That all worked fine, and now I'm trying to reference the DLL in a .NET 3.5 C# project.

In my C# project, I've created an static "StringExtensions" class with an extension method on string.

For some reason this seemed to work yesterday, but today, I'm getting a build error on my extension class (not sure how this worked yesterday...).

Missing compiler required member System.Runtime.CompilerServices.ExtensionAttribute..ctor

And a build warning as well:

The predefined type 'System.Runtime.CompilerServices.ExtensionAttribute' is defined in multiple assemblies in the global alias; using definition from 'c:\TEMP\IKVM.Runtime.dll'

I discovered that both IKVM.Runtime.dll and System.Core.dll (3.5 version) have the same type: "System.Runtime.CompilerServices.ExtensionAttribute"

Since the namespace is the same, how can I get this to compile with the System.Core version of ExtensionAttribute (or how can I fix this)?

Thanks

+1  A: 

If you target .Net 2.0 you can only create extension methods if you define this attribute yourself. This works great until you move to .Net 3.5.

I don't know "IKVM" but the only real fix is to ask them to remove the attribute and target 3.5.

chris
+2  A: 

Updating to IKVM 0.40.0.1 fixed this problem for me.

Luke Quinane