diff --git a/runtime/ClassLoaderWrapper.cs b/runtime/ClassLoaderWrapper.cs index f9b8c090..feeb2728 100644 --- a/runtime/ClassLoaderWrapper.cs +++ b/runtime/ClassLoaderWrapper.cs @@ -1761,10 +1761,7 @@ namespace IKVM.Internal { if (delegates == null) { -#pragma warning disable 184 - // during ikvmc build: warning CS0184: The given expression is never of the provided ('IKVM.Reflection.Emit.AssemblyBuilder') type - if (!(assemblyLoader.Assembly is AssemblyBuilder) && assemblyLoader.Assembly.GetManifestResourceInfo("ikvm.exports") != null) -#pragma warning restore 184 + if (!(ReflectUtil.IsDynamicAssembly(assemblyLoader.Assembly)) && assemblyLoader.Assembly.GetManifestResourceInfo("ikvm.exports") != null) { List wildcardExports = new List(); using (Stream stream = assemblyLoader.Assembly.GetManifestResourceStream("ikvm.exports")) @@ -2042,6 +2039,10 @@ namespace IKVM.Internal #if !STATIC_COMPILER internal Assembly FindResourceAssembliesImpl(string unmangledName, string name, bool firstOnly, ref List list) { + if(ReflectUtil.IsDynamicAssembly(assemblyLoader.Assembly)) + { + return null; + } if(assemblyLoader.Assembly.GetManifestResourceInfo(name) != null) { if(firstOnly) @@ -2096,6 +2097,7 @@ namespace IKVM.Internal { return new Assembly[] { first }; } + LazyInitExports(); for(int i = 0; i < delegates.Length; i++) { if(delegates[i] == null) diff --git a/runtime/DynamicClassLoader.cs b/runtime/DynamicClassLoader.cs index e7572d4d..25685049 100644 --- a/runtime/DynamicClassLoader.cs +++ b/runtime/DynamicClassLoader.cs @@ -427,24 +427,6 @@ namespace IKVM.Internal assemblyBuilder.SetCustomAttribute(debugAttr); return JVM.IsSaveDebugImage ? assemblyBuilder.DefineDynamicModule("ikvmdump.dll", "ikvmdump.dll", debug) : assemblyBuilder.DefineDynamicModule(name.Name, debug); } - - internal static bool IsDynamicAssembly(Assembly asm) - { -#if NET_4_0 - return asm.IsDynamic(); -#else - if (asm is System.Reflection.Emit.AssemblyBuilder) - { - return true; - } - if (asm.Equals(Instance.ModuleBuilder.Assembly)) - { - // this can happen on Orcas, where an AssemblyBuilder has a corresponding Assembly - return true; - } - return false; -#endif - } #endif // !STATIC_COMPILER } } diff --git a/runtime/ReflectUtil.cs b/runtime/ReflectUtil.cs index de651bb7..3d8f9a5a 100644 --- a/runtime/ReflectUtil.cs +++ b/runtime/ReflectUtil.cs @@ -65,5 +65,17 @@ namespace IKVM.Internal return type.Assembly; } #endif + + internal static bool IsDynamicAssembly(Assembly asm) + { +#if NET_4_0 + return asm.IsDynamic(); +#else + // HACK pre-.NET 4.0 there is no API for this + string manifest = asm.ManifestModule.Name; + return manifest == "" // .NET name + || manifest == "Default Dynamic Module"; // Mono name +#endif + } } } diff --git a/runtime/common.cs b/runtime/common.cs index 0db995b8..acdf0b61 100644 --- a/runtime/common.cs +++ b/runtime/common.cs @@ -310,7 +310,7 @@ namespace IKVM.NativeCode.ikvm.runtime { public static object loadClassFromAssembly(Assembly asm, string className) { - if(DynamicClassLoader.IsDynamicAssembly(asm)) + if(ReflectUtil.IsDynamicAssembly(asm)) { return null; } @@ -320,7 +320,7 @@ namespace IKVM.NativeCode.ikvm.runtime public static bool findResourceInAssembly(Assembly asm, string resourceName) { - if(DynamicClassLoader.IsDynamicAssembly(asm)) + if(ReflectUtil.IsDynamicAssembly(asm)) { return false; }