【发布时间】:2009-03-25 15:58:49
【问题描述】:
我正在使用最新版本的 IKVM 将 Java .jar 文件“编译”成 .NET DLL。一切正常,现在我尝试在 .NET 3.5 C# 项目中引用 DLL。
在我的 C# 项目中,我创建了一个静态“StringExtensions”类,其中包含一个字符串扩展方法。
由于某种原因,这似乎在昨天有效,但今天,我的扩展类出现构建错误(不确定昨天是如何工作的......)。
Missing compiler required member System.Runtime.CompilerServices.ExtensionAttribute..ctor
还有一个构建警告:
The predefined type 'System.Runtime.CompilerServices.ExtensionAttribute' is defined in multiple assemblies in the global alias; using definition from 'c:\TEMP\IKVM.Runtime.dll'
我发现 IKVM.Runtime.dll 和 System.Core.dll(3.5 版本)都有相同的类型:“System.Runtime.CompilerServices.ExtensionAttribute”
由于命名空间相同,我怎样才能让它与 ExtensionAttribute 的 System.Core 版本一起编译(或者我该如何解决这个问题)?
谢谢
【问题讨论】:
-
我通过摆脱所有扩展方法来解决这个问题,但我仍然很好奇。似乎任何项目中存在 IKVM.Runtime.dll 都会导致扩展方法出现问题。
标签: c# .net extension-methods ikvm build-error