internal static RuntimeModule GetModule(RuntimeType type) { RuntimeModule?res = null; GetModule(new QCallTypeHandle(ref type), ObjectHandleOnStack.Create(ref res)); return(res !); }
[System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod private static RuntimeModule GetDynamicMethodsModule() { if (s_anonymouslyHostedDynamicMethodsModule != null) { return(s_anonymouslyHostedDynamicMethodsModule); } lock (s_anonymouslyHostedDynamicMethodsModuleLock) { if (s_anonymouslyHostedDynamicMethodsModule != null) { return(s_anonymouslyHostedDynamicMethodsModule); } AssemblyName assemblyName = new AssemblyName("Anonymously Hosted DynamicMethods Assembly"); AssemblyBuilder assembly = AssemblyBuilder.InternalDefineDynamicAssembly( assemblyName, AssemblyBuilderAccess.Run, typeof(object).Assembly, null, null); // this always gets the internal module. s_anonymouslyHostedDynamicMethodsModule = (RuntimeModule)assembly.ManifestModule !; } return(s_anonymouslyHostedDynamicMethodsModule); }
[System.Security.DynamicSecurityMethod] // Methods containing StackCrawlMark local var has to be marked DynamicSecurityMethod private static RuntimeModule GetDynamicMethodsModule() { if (s_anonymouslyHostedDynamicMethodsModule != null) { return(s_anonymouslyHostedDynamicMethodsModule); } lock (s_anonymouslyHostedDynamicMethodsModuleLock) { if (s_anonymouslyHostedDynamicMethodsModule != null) { return(s_anonymouslyHostedDynamicMethodsModule); } AssemblyName assemblyName = new AssemblyName("Anonymously Hosted DynamicMethods Assembly"); StackCrawlMark stackMark = StackCrawlMark.LookForMe; AssemblyBuilder assembly = AssemblyBuilder.InternalDefineDynamicAssembly( assemblyName, AssemblyBuilderAccess.Run, ref stackMark, null, null); // this always gets the internal module. s_anonymouslyHostedDynamicMethodsModule = (RuntimeModule)assembly.ManifestModule !; } return(s_anonymouslyHostedDynamicMethodsModule); }
public override FileStream?GetFile(string name) { RuntimeModule?m = (RuntimeModule?)GetModule(name); if (m == null) { return(null); } return(new FileStream(m.GetFullyQualifiedName(), FileMode.Open, FileAccess.Read, FileShare.Read, FileStream.DefaultBufferSize, false)); }
public override FileStream?GetFile(string name) { if (Location.Length == 0) { // Throw if the assembly was loaded from memory, indicated by Location returning an empty string throw new FileNotFoundException(SR.IO_NoFileTableInInMemoryAssemblies); } RuntimeModule?m = (RuntimeModule?)GetModule(name); if (m == null) { return(null); } return(new FileStream(m.GetFullyQualifiedName(), FileMode.Open, FileAccess.Read, FileShare.Read, FileStream.DefaultBufferSize, false)); }