Question

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

Was it helpful?

Solution

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.

OTHER TIPS

Updating to IKVM 0.40.0.1 fixed this problem for me.

I have the same problem.

In my case the problem was the assembly Mono.Cecil.

Migrating from local references to nuget, when i add NHibernate references the package automatically adds this reference.

This reference was removed, and compiled my project again.

You need do understand this implementation to solve your question. One of both assemblies must be removed.

This image was taken from ILSpy ( http://i.stack.imgur.com/Qyd5o.png )

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top