We need you! We're working hard on the next version of Developer Fusion -
Let us know what you think we should be up to!
-
Expand
Microsoft.Win32
-
Expand
Microsoft.Win32.SafeHandles
-
Expand
System
-
Expand
System.Runtime.Hosting
-
Expand
System.Runtime.InteropServices
-
Expand
System.Runtime.CompilerServices
-
Expand
System.Collections
-
Expand
System.Collections.Generic
-
Expand
System.Collections.ObjectModel
-
Expand
System.Configuration.Assemblies
-
Expand
System.Diagnostics
-
Expand
System.Diagnostics.CodeAnalysis
-
Expand
System.Diagnostics.SymbolStore
-
Expand
System.Globalization
-
Expand
System.IO
-
Expand
System.IO.IsolatedStorage
-
Expand
System.Reflection
-
Expand
System.Reflection.Cache
-
Expand
System.Reflection.Emit
-
Expand
__ExceptionInfo
-
Expand
__ExceptionInstance
-
Expand
__FixupData
-
Expand
AssemblyBuilder
-
AddResourceFile(string, string)
-
AddResourceFile(string, string, ResourceAttributes)
-
AddResourceFileNoLock(string, string, ResourceAttributes)
-
AssemblyBuilder()
-
CheckContext(Type)
-
CheckContext(Type)
-
CodeBase()
-
DefineDynamicModule(string)
-
DefineDynamicModule(string, bool)
-
DefineDynamicModule(string, string)
-
DefineDynamicModule(string, string, bool)
-
DefineDynamicModuleInternal(string, bool, StackCrawlMark)
-
DefineDynamicModuleInternal(string, string, bool, StackCrawlMark)
-
DefineDynamicModuleInternalNoLock(string, string, bool, StackCrawlMark)
-
DefineNestedComType(Type, int, int)
-
DefineResource(string, string, string)
-
DefineResource(string, string, string, ResourceAttributes)
-
DefineResourceNoLock(string, string, string, ResourceAttributes)
-
EntryPoint()
-
GetDynamicModule(string)
-
GetDynamicModuleNoLock(string)
-
GetExportedTypes()
-
GetFile(string)
-
GetFiles(bool)
-
GetIDsOfNames(Guid, IntPtr, uint, uint, IntPtr)
-
GetManifestResourceInfo(string)
-
GetManifestResourceNames()
-
GetManifestResourceStream(string)
-
GetManifestResourceStream(Type, string)
-
GetTypeInfo(uint, uint, IntPtr)
-
GetTypeInfoCount(uint)
-
ImageRuntimeVersion()
-
Invoke(uint, Guid, uint, short, IntPtr, IntPtr, IntPtr, IntPtr)
-
IsPersistable()
-
LoadISymWrapper()
-
Location()
-
ReflectionOnly()
-
Save(string)
-
Save(string, PortableExecutableKinds, ImageFileMachine)
-
SaveNoLock(string, PortableExecutableKinds, ImageFileMachine)
-
SetCustomAttribute(ConstructorInfo, byte)
-
SetCustomAttribute(CustomAttributeBuilder)
-
SetEntryPoint(MethodInfo)
-
SetEntryPoint(MethodInfo, PEFileKinds)
-
SetEntryPointNoLock(MethodInfo, PEFileKinds)
-
Expand
AssemblyBuilderAccess
-
Expand
AssemblyBuilderData
-
Expand
ConstructorBuilder
-
Expand
ConstructorOnTypeBuilderInstantiation
-
Expand
CustAttr
-
Expand
CustomAttributeBuilder
-
Expand
DestroyScout
-
Expand
DynamicILGenerator
-
Expand
DynamicILInfo
-
Expand
DynamicMethod
-
Expand
DynamicResolver
-
Expand
DynamicScope
-
Expand
EmptyCAHolder
-
Expand
Entry
-
Expand
EnumBuilder
-
Expand
EventBuilder
-
Expand
EventToken
-
Expand
FieldBuilder
-
Expand
FieldOnTypeBuilderInstantiation
-
Expand
FieldToken
-
Expand
FlowControl
-
Expand
Format
-
Expand
GenericMethodInfo
-
Expand
GenericTypeParameterBuilder
-
Expand
ILGenerator
-
Expand
Label
-
Expand
LineNumberInfo
-
Expand
LocalBuilder
-
Expand
LocalSymInfo
-
Expand
MethodBuilder
-
Expand
MethodBuilderInstantiation
-
Expand
MethodOnTypeBuilderInstantiation
-
Expand
MethodRental
-
Expand
MethodToken
-
Expand
ModuleBuilder
-
Expand
ModuleBuilderData
-
Expand
OpCode
-
Expand
OpCodes
-
Expand
OpCodeType
-
Expand
OperandType
-
Expand
PackingSize
-
Expand
ParameterBuilder
-
Expand
ParameterToken
-
Expand
PEFileKinds
-
Expand
PropertyBuilder
-
Expand
PropertyToken
-
Expand
REDocument
-
Expand
ResWriterData
-
Expand
RTDynamicMethod
-
Expand
ScopeAction
-
Expand
ScopeTree
-
Expand
SecurityControlFlags
-
Expand
SignatureHelper
-
Expand
SignatureToken
-
Expand
StackBehaviour
-
Expand
StringToken
-
Expand
SymbolMethod
-
Expand
SymbolType
-
Expand
SymCustomAttr
-
Expand
TypeBuilder
-
Expand
TypeBuilderInstantiation
-
Expand
TypeKind
-
Expand
TypeNameBuilder
-
Expand
TypeToken
-
Expand
UnmanagedMarshal
-
Expand
VarArgMethod
-
Expand
System.Resources
-
Expand
System.Runtime
-
Expand
System.Runtime.InteropServices.Expando
-
Expand
System.Runtime.ConstrainedExecution
-
Expand
System.Runtime.Remoting.Activation
-
Expand
System.Runtime.Remoting.Messaging
-
Expand
System.Runtime.Remoting.Channels
-
Expand
System.Runtime.Remoting.Lifetime
-
Expand
System.Runtime.Remoting
-
Expand
System.Runtime.Remoting.Contexts
-
Expand
System.Runtime.Remoting.Proxies
-
Expand
System.Runtime.Remoting.Metadata
-
Expand
System.Runtime.Remoting.Metadata.W3cXsd2001
-
Expand
System.Runtime.Remoting.Services
-
Expand
System.Runtime.Serialization
-
Expand
System.Runtime.Serialization.Formatters
-
Expand
System.Runtime.Serialization.Formatters.Binary
-
Expand
System.Runtime.Versioning
-
Expand
System.Security
-
Expand
System.Security.Cryptography
-
Expand
System.Security.Cryptography.X509Certificates
-
Expand
System.Security.Permissions
-
Expand
System.Security.Policy
-
Expand
System.Security.Principal
-
Expand
System.Security.Util
-
Expand
System.Text
-
Expand
System.Threading
-
Expand
System.Runtime.Remoting.Channels.Http
-
Expand
System.Runtime.Remoting.Channels.Tcp
-
Expand
System.Runtime.Remoting.MetadataServices
-
Expand
System.Runtime.Serialization.Formatters.Soap.Xml
-
Expand
System.Runtime.Serialization.Formatters.Soap
-
Expand
Microsoft.Tools.Caspol
-
Expand
Microsoft.Tools.Build
-
Expand
Microsoft.CSharp
-
Expand
System.CodeDom
-
Expand
System.CodeDom.Compiler
-
Expand
System.Collections.Specialized
-
Expand
System.ComponentModel
-
Expand
System.ComponentModel.Design
-
Expand
System.ComponentModel.Design.Serialization
-
Expand
System.Configuration
-
Expand
System.Web
-
Expand
System.Configuration.Provider
-
Expand
System.Configuration.Internal
-
Expand
System.Internal
-
Expand
System.Windows.Forms
-
Expand
System.Net
-
Expand
System.Net.Sockets
-
Expand
System.Net.NetworkInformation
-
Expand
System.Net.ComImports
-
Expand
System.Net.Security
-
Expand
System.Net.Cache
-
Expand
System.Net.Configuration
-
Expand
System.Text.RegularExpressions
-
Expand
System.Tools
-
Expand
System.IO.Compression
-
Expand
System.IO.Ports
-
Expand
System.Security.AccessControl
-
Expand
System.Xml
-
Expand
System.Xml.XPath.DataBinding
-
Expand
System.Xml.Schema
-
Expand
System.Xml.Serialization
-
Expand
System.Xml.Serialization.Advanced
-
Expand
System.Xml.Serialization.Configuration
-
Expand
System.Xml.XPath
-
Expand
System.Xml.Xsl
-
Expand
System.Xml.Xsl.IlGen
-
Expand
System.Xml.Xsl.Qil
-
Expand
System.Xml.Xsl.Runtime
-
Expand
System.Xml.Xsl.XPath
-
Expand
System.Xml.Xsl.Xslt
-
Expand
System.Xml.Xsl.XsltOld
-
Expand
System.Xml.Xsl.XsltOld.Debugger
-
Expand
Microsoft.JScript
-
Expand
Microsoft.Vsa
-
Expand
Microsoft.JScript.Vsa
- namespace System.Reflection.Emit
- {
- using System;
- using System.IO;
- using System.Diagnostics.SymbolStore;
- using System.Reflection;
- using System.Diagnostics;
- using System.Resources;
- using System.Security.Permissions;
- using System.Runtime.Remoting.Activation;
- using CultureInfo = System.Globalization.CultureInfo;
- using System.Runtime.Serialization;
- using System.Security;
- using System.Threading;
- using System.Runtime.CompilerServices;
- using System.Runtime.InteropServices;
- using System.Runtime.Versioning;
-
-
-
- [HostProtection(MayLeakOnAbort = true)]
- [ClassInterface(ClassInterfaceType.None)]
- [ComDefaultInterface(typeof(_AssemblyBuilder))]
- [ComVisible(true)]
- public sealed class AssemblyBuilder : Assembly, _AssemblyBuilder
- {
-
-
- public ModuleBuilder DefineDynamicModule(string name)
- {
- CodeAccessPermission.DemandInternal(PermissionType.ReflectionEmit);
-
- StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
- return DefineDynamicModuleInternal(name, false, ref stackMark);
- }
-
-
- public ModuleBuilder DefineDynamicModule(string name, bool emitSymbolInfo)
- {
- CodeAccessPermission.DemandInternal(PermissionType.ReflectionEmit);
-
- StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
- return DefineDynamicModuleInternal(name, emitSymbolInfo, ref stackMark);
- }
-
-
- internal ModuleBuilder DefineDynamicModuleInternal(string name, bool emitSymbolInfo, ref StackCrawlMark stackMark)
- {
- BCLDebug.Log("DYNIL", "## DYNIL LOGGING: AssemblyBuilder.DefineDynamicModule( " + name + " )");
-
- BCLDebug.Assert(m_assemblyData != null, "m_assemblyData is null in DefineDynamicModuleInternal");
-
- if (name == null)
- throw new ArgumentNullException("name");
- if (name.Length == 0)
- throw new ArgumentException(Environment.GetResourceString("Argument_EmptyName"), "name");
- if (name[0] == '\0')
- throw new ArgumentException(Environment.GetResourceString("Argument_InvalidName"), "name");
-
- m_assemblyData.CheckNameConflict(name);
-
-
- ModuleBuilder dynModule = nDefineDynamicModule(this, emitSymbolInfo, name, ref stackMark);
- ISymbolWriter writer = null;
-
- if (emitSymbolInfo) {
-
- Assembly assem = LoadISymWrapper();
- Type symWriter = assem.GetType("System.Diagnostics.SymbolStore.SymWriter", true, false);
- if (symWriter != null && !symWriter.IsVisible)
- symWriter = null;
-
- if (symWriter == null) {
-
- throw new ExecutionEngineException(String.Format(CultureInfo.CurrentCulture, Environment.GetResourceString(ResId.MissingType), "SymWriter"));
- }
- try {
- (new PermissionSet(PermissionState.Unrestricted)).Assert();
- writer = (ISymbolWriter)Activator.CreateInstance(symWriter);
- }
- finally {
- CodeAccessPermission.RevertAssert();
- }
- }
-
- dynModule.Init(name, null, writer);
- m_assemblyData.AddModule(dynModule);
- return dynModule;
- }
-
- private Assembly LoadISymWrapper()
- {
- if (m_assemblyData.m_ISymWrapperAssembly != null)
- return m_assemblyData.m_ISymWrapperAssembly;
-
- Assembly assem = Assembly.Load("ISymWrapper, Version=" + ThisAssembly.Version + ", Culture=neutral, PublicKeyToken=" + AssemblyRef.MicrosoftPublicKeyToken);
-
- m_assemblyData.m_ISymWrapperAssembly = assem;
- return assem;
- }
-
-
- public ModuleBuilder DefineDynamicModule(string name, string fileName)
- {
- CodeAccessPermission.DemandInternal(PermissionType.ReflectionEmit);
-
- StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
-
-
- return DefineDynamicModuleInternal(name, fileName, false, ref stackMark);
- }
-
-
-
-
-
- public ModuleBuilder DefineDynamicModule(string name, string fileName, bool emitSymbolInfo)
- {
- CodeAccessPermission.DemandInternal(PermissionType.ReflectionEmit);
- StackCrawlMark stackMark = StackCrawlMark.LookForMyCaller;
- return DefineDynamicModuleInternal(name, fileName, emitSymbolInfo, ref stackMark);
- }
-
-
-
-
-
- private ModuleBuilder DefineDynamicModuleInternal(string name, string fileName, bool emitSymbolInfo, ref StackCrawlMark stackMark)
- {
- if (m_assemblyData.m_isSynchronized) {
- lock (m_assemblyData) {
- return DefineDynamicModuleInternalNoLock(name, fileName, emitSymbolInfo, ref stackMark);
- }
- }
- else {
- return DefineDynamicModuleInternalNoLock(name, fileName, emitSymbolInfo, ref stackMark);
- }
- }
-
- public override bool ReflectionOnly {
- get { return base.ReflectionOnly; }
- }
-
- internal void CheckContext(params Type[][] typess)
- {
- if (typess == null)
- return;
-
- foreach (Type[] types in typess)
- if (types != null)
- CheckContext(types);
- }
-
- internal void CheckContext(params Type[] types)
- {
- if (types == null)
- return;
-
- foreach (Type type in types) {
- if (type == null || type.Module.Assembly == typeof(object).Module.Assembly)
- return;
- if (type.Module.Assembly.ReflectionOnly && !ReflectionOnly)
- throw new InvalidOperationException(String.Format(CultureInfo.CurrentCulture, Environment.GetResourceString("Arugment_EmitMixedContext1"), type.AssemblyQualifiedName));
-
- if (!type.Module.Assembly.ReflectionOnly && ReflectionOnly)
- throw new InvalidOperationException(String.Format(CultureInfo.CurrentCulture, Environment.GetResourceString("Arugment_EmitMixedContext2"), type.AssemblyQualifiedName));
- }
- }
-
-
-
-
-
- private ModuleBuilder DefineDynamicModuleInternalNoLock(string name, string fileName, bool emitSymbolInfo, ref StackCrawlMark stackMark)
- {
- BCLDebug.Log("DYNIL", "## DYNIL LOGGING: AssemblyBuilder.DefineDynamicModule( " + name + ", " + fileName + ", " + emitSymbolInfo + " )");
- if (m_assemblyData.m_access == AssemblyBuilderAccess.Run) {
-
- throw new NotSupportedException(Environment.GetResourceString("Argument_BadPersistableModuleInTransientAssembly"));
- }
-
- if (m_assemblyData.m_isSaved == true) {
-
- throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_CannotAlterAssembly"));
- }
-
- if (name == null)
- throw new ArgumentNullException("name");
- if (name.Length == 0)
- throw new ArgumentException(Environment.GetResourceString("Argument_EmptyName"), "name");
- if (name[0] == '\0')
- throw new ArgumentException(Environment.GetResourceString("Argument_InvalidName"), "name");
-
- if (fileName == null)
- throw new ArgumentNullException("fileName");
- if (fileName.Length == 0)
- throw new ArgumentException(Environment.GetResourceString("Argument_EmptyFileName"), "fileName");
- if (!String.Equals(fileName, Path.GetFileName(fileName)))
- throw new ArgumentException(Environment.GetResourceString("Argument_NotSimpleFileName"), "fileName");
-
- m_assemblyData.CheckNameConflict(name);
- m_assemblyData.CheckFileNameConflict(fileName);
-
-
- ModuleBuilder dynModule = nDefineDynamicModule(this, emitSymbolInfo, fileName, ref stackMark);
- ISymbolWriter writer = null;
-
- if (emitSymbolInfo) {
-
- Assembly assem = LoadISymWrapper();
- Type symWriter = assem.GetType("System.Diagnostics.SymbolStore.SymWriter", true, false);
- if (symWriter != null && !symWriter.IsVisible)
- symWriter = null;
-
- if (symWriter == null) {
-
- throw new ExecutionEngineException(String.Format(CultureInfo.CurrentCulture, Environment.GetResourceString("MissingType"), "SymWriter"));
- }
- try {
- (new PermissionSet(PermissionState.Unrestricted)).Assert();
- writer = (ISymbolWriter)Activator.CreateInstance(symWriter);
- }
- finally {
- CodeAccessPermission.RevertAssert();
- }
-
- }
-
-
- dynModule.Init(name, fileName, writer);
- m_assemblyData.AddModule(dynModule);
- return dynModule;
- }
-
-
-
- [ResourceExposure(ResourceScope.Machine)]
- [ResourceConsumption(ResourceScope.Machine)]
- public IResourceWriter DefineResource(string name, string description, string fileName)
- {
- return DefineResource(name, description, fileName, ResourceAttributes.Public);
- }
-
-
- [ResourceExposure(ResourceScope.Machine)]
- [ResourceConsumption(ResourceScope.Machine)]
- public IResourceWriter DefineResource(string name, string description, string fileName, ResourceAttributes attribute)
- {
- if (m_assemblyData.m_isSynchronized) {
- lock (m_assemblyData) {
- return DefineResourceNoLock(name, description, fileName, attribute);
- }
- }
- else {
- return DefineResourceNoLock(name, description, fileName, attribute);
- }
- }
-
- [ResourceExposure(ResourceScope.Machine)]
- [ResourceConsumption(ResourceScope.Machine)]
- private IResourceWriter DefineResourceNoLock(string name, string description, string fileName, ResourceAttributes attribute)
- {
- CodeAccessPermission.DemandInternal(PermissionType.ReflectionEmit);
- BCLDebug.Log("DYNIL", "## DYNIL LOGGING: AssemblyBuilder.DefineResource( " + name + ", " + fileName + ")");
-
- if (name == null)
- throw new ArgumentNullException("name");
- if (name.Length == 0)
- throw new ArgumentException(Environment.GetResourceString("Argument_EmptyName"), name);
- if (fileName == null)
- throw new ArgumentNullException("fileName");
- if (fileName.Length == 0)
- throw new ArgumentException(Environment.GetResourceString("Argument_EmptyFileName"), "fileName");
- if (!String.Equals(fileName, Path.GetFileName(fileName)))
- throw new ArgumentException(Environment.GetResourceString("Argument_NotSimpleFileName"), "fileName");
-
- m_assemblyData.CheckResNameConflict(name);
- m_assemblyData.CheckFileNameConflict(fileName);
-
- ResourceWriter resWriter;
- string fullFileName;
-
- if (m_assemblyData.m_strDir == null) {
-
- fullFileName = Path.Combine(Environment.CurrentDirectory, fileName);
- resWriter = new ResourceWriter(fullFileName);
- }
- else {
-
- fullFileName = Path.Combine(m_assemblyData.m_strDir, fileName);
- resWriter = new ResourceWriter(fullFileName);
- }
-
- fullFileName = Path.GetFullPath(fullFileName);
-
-
- fileName = Path.GetFileName(fullFileName);
-
- m_assemblyData.AddResWriter(new ResWriterData(resWriter, null, name, fileName, fullFileName, attribute));
- return resWriter;
- }
-
-
-
- [ResourceExposure(ResourceScope.Machine)]
- [ResourceConsumption(ResourceScope.Machine)]
- public void AddResourceFile(string name, string fileName)
- {
- AddResourceFile(name, fileName, ResourceAttributes.Public);
- }
-
-
- [ResourceExposure(ResourceScope.Machine)]
- [ResourceConsumption(ResourceScope.Machine)]
- public void AddResourceFile(string name, string fileName, ResourceAttributes attribute)
- {
- CodeAccessPermission.DemandInternal(PermissionType.ReflectionEmit);
- if (m_assemblyData.m_isSynchronized) {
- lock (m_assemblyData) {
- AddResourceFileNoLock(name, fileName, attribute);
- }
- }
- else {
- AddResourceFileNoLock(name, fileName, attribute);
- }
- }
-
- [ResourceExposure(ResourceScope.Machine)]
- [ResourceConsumption(ResourceScope.Machine)]
- private void AddResourceFileNoLock(string name, string fileName, ResourceAttributes attribute)
- {
- BCLDebug.Log("DYNIL", "## DYNIL LOGGING: AssemblyBuilder.AddResourceFile( " + name + ", " + fileName + ")");
-
- if (name == null)
- throw new ArgumentNullException("name");
- if (name.Length == 0)
- throw new ArgumentException(Environment.GetResourceString("Argument_EmptyName"), name);
- if (fileName == null)
- throw new ArgumentNullException("fileName");
- if (fileName.Length == 0)
- throw new ArgumentException(Environment.GetResourceString("Argument_EmptyFileName"), fileName);
- if (!String.Equals(fileName, Path.GetFileName(fileName)))
- throw new ArgumentException(Environment.GetResourceString("Argument_NotSimpleFileName"), "fileName");
-
- m_assemblyData.CheckResNameConflict(name);
- m_assemblyData.CheckFileNameConflict(fileName);
-
- string fullFileName;
-
- if (m_assemblyData.m_strDir == null) {
-
- fullFileName = Path.Combine(Environment.CurrentDirectory, fileName);
- }
- else {
-
- fullFileName = Path.Combine(m_assemblyData.m_strDir, fileName);
- }
-
-
- fullFileName = Path.GetFullPath(fullFileName);
-
-
- fileName = Path.GetFileName(fullFileName);
-
- if (File.Exists(fullFileName) == false)
- throw new FileNotFoundException(String.Format(CultureInfo.CurrentCulture, Environment.GetResourceString("IO.FileNotFound_FileName"), fileName), fileName);
- m_assemblyData.AddResWriter(new ResWriterData(null, null, name, fileName, fullFileName, attribute));
- }
-
-
- public override string[] GetManifestResourceNames()
- {
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_DynamicModule"));
- }
-
- public override FileStream GetFile(string name)
- {
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_DynamicModule"));
- }
-
- public override FileStream[] GetFiles(bool getResourceModules)
- {
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_DynamicModule"));
- }
-
- public override Stream GetManifestResourceStream(Type type, string name)
- {
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_DynamicModule"));
- }
-
- public override Stream GetManifestResourceStream(string name)
- {
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_DynamicModule"));
- }
-
- public override ManifestResourceInfo GetManifestResourceInfo(string resourceName)
- {
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_DynamicModule"));
- }
-
- public override string Location {
- get {
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_DynamicModule"));
- }
- }
-
- public override string ImageRuntimeVersion {
- get { return RuntimeEnvironment.GetSystemVersion(); }
- }
-
- public override string CodeBase {
- get {
- throw new NotSupportedException(Environment.GetResourceString("NotSupported_DynamicModule"));
- }
- }
-
-
-
-
-
-
-
- public ModuleBuilder GetDynamicModule(string name)
- {
- if (m_assemblyData.m_isSynchronized) {
- lock (m_assemblyData) {
- return GetDynamicModuleNoLock(name);
- }
- }
- else {
- return GetDynamicModuleNoLock(name);
- }
- }
-
-
- private ModuleBuilder GetDynamicModuleNoLock(string name)
- {
- BCLDebug.Log("DYNIL", "## DYNIL LOGGING: AssemblyBuilder.GetDynamicModule( " + name + " )");
- if (name == null)
- throw new ArgumentNullException("name");
- if (name.Length == 0)
- throw new ArgumentException(Environment.GetResourceString("Argument_EmptyName"), "name");
-
- int size = m_assemblyData.m_moduleBuilderList.Count;
- for (int i = 0; i < size; i++) {
- ModuleBuilder moduleBuilder = (ModuleBuilder)m_assemblyData.m_moduleBuilderList[i];
- if (moduleBuilder.m_moduleData.m_strModuleName.Equals(name)) {
- return moduleBuilder;
- }
- }
- return null;
- }
-
-
- public void SetEntryPoint(MethodInfo entryMethod)
- {
- SetEntryPoint(entryMethod, PEFileKinds.ConsoleApplication);
- }
-
-
- public void SetEntryPoint(MethodInfo entryMethod, PEFileKinds fileKind)
- {
- CodeAccessPermission.DemandInternal(PermissionType.ReflectionEmit);
- if (m_assemblyData.m_isSynchronized) {
- lock (m_assemblyData) {
- SetEntryPointNoLock(entryMethod, fileKind);
- }
- }
- else {
- SetEntryPointNoLock(entryMethod, fileKind);
- }
- }
-
-
-
- private void SetEntryPointNoLock(MethodInfo entryMethod, PEFileKinds fileKind)
- {
-
- BCLDebug.Log("DYNIL", "## DYNIL LOGGING: AssemblyBuilder.SetEntryPoint");
- if (entryMethod == null)
- throw new ArgumentNullException("entryMethod");
-
-
-
- Module tmpModule = entryMethod.Module;
- if (!(tmpModule is ModuleBuilder && this.Equals(tmpModule.Assembly)))
- throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_EntryMethodNotDefinedInAssembly"));
- m_assemblyData.m_entryPointModule = (ModuleBuilder)tmpModule;
- m_assemblyData.m_entryPointMethod = entryMethod;
- m_assemblyData.m_peFileKind = fileKind;
- m_assemblyData.m_entryPointModule.SetEntryPoint(entryMethod);
- }
-
-
-
- public override MethodInfo EntryPoint {
- get { return m_assemblyData.m_entryPointMethod; }
- }
-
-
- [System.Runtime.InteropServices.ComVisible(true)]
- public void SetCustomAttribute(ConstructorInfo con, byte[] binaryAttribute)
- {
- CodeAccessPermission.DemandInternal(PermissionType.ReflectionEmit);
- if (con == null)
- throw new ArgumentNullException("con");
- if (binaryAttribute == null)
- throw new ArgumentNullException("binaryAttribute");
-
- ModuleBuilder inMemoryAssemblyModule;
- inMemoryAssemblyModule = m_assemblyData.GetInMemoryAssemblyModule();
-
-
- TypeBuilder.InternalCreateCustomAttribute(AssemblyBuilderData.m_tkAssembly, inMemoryAssemblyModule.GetConstructorToken(con).Token, binaryAttribute, inMemoryAssemblyModule, false, typeof(System.Diagnostics.DebuggableAttribute) == con.DeclaringType);
-
-
- if (m_assemblyData.m_access == AssemblyBuilderAccess.Run) {
- return;
- }
-
-
- m_assemblyData.AddCustomAttribute(con, binaryAttribute);
- }
-
-
- public void SetCustomAttribute(CustomAttributeBuilder customBuilder)
- {
- CodeAccessPermission.DemandInternal(PermissionType.ReflectionEmit);
- if (customBuilder == null) {
- throw new ArgumentNullException("customBuilder");
- }
-
- ModuleBuilder inMemoryAssemblyModule;
- inMemoryAssemblyModule = m_assemblyData.GetInMemoryAssemblyModule();
- customBuilder.CreateCustomAttribute(inMemoryAssemblyModule, AssemblyBuilderData.m_tkAssembly);
-
-
- if (m_assemblyData.m_access == AssemblyBuilderAccess.Run) {
- return;
- }
- m_assemblyData.AddCustomAttribute(customBuilder);
- }
-
-
-
-
- [ResourceExposure(ResourceScope.Machine)]
- [ResourceConsumption(ResourceScope.Machine)]
-
- public void Save(string assemblyFileName)
- {
- Save(assemblyFileName, System.Reflection.PortableExecutableKinds.ILOnly, System.Reflection.ImageFileMachine.I386);
- }
-
- [ResourceExposure(ResourceScope.Machine)]
- [ResourceConsumption(ResourceScope.Machine)]
- public void Save(string assemblyFileName, PortableExecutableKinds portableExecutableKind, ImageFileMachine imageFileMachine)
- {
- if (m_assemblyData.m_isSynchronized) {
- lock (m_assemblyData) {
- SaveNoLock(assemblyFileName, portableExecutableKind, imageFileMachine);
- }
- }
- else {
- SaveNoLock(assemblyFileName, portableExecutableKind, imageFileMachine);
- }
- }
-
- [ResourceExposure(ResourceScope.Machine)]
- [ResourceConsumption(ResourceScope.Machine)]
- private void SaveNoLock(string assemblyFileName, PortableExecutableKinds portableExecutableKind, ImageFileMachine imageFileMachine)
- {
- int i;
- int size;
- Type type;
- TypeBuilder typeBuilder;
- ModuleBuilder modBuilder;
- string strModFileName;
- ModuleBuilder assemblyModule;
- ResWriterData tempRes;
- int[] tkAttrs = null;
- int[] tkAttrs2 = null;
- ModuleBuilder onDiskAssemblyModule;
-
- BCLDebug.Log("DYNIL", "## DYNIL LOGGING: AssemblyBuilder.Save( " + assemblyFileName + " )");
-
- string tmpVersionFile = null;
-
- try {
- if (m_assemblyData.m_iCABuilder != 0)
- tkAttrs = new int[m_assemblyData.m_iCABuilder];
- if (m_assemblyData.m_iCAs != 0)
- tkAttrs2 = new int[m_assemblyData.m_iCAs];
-
- if (m_assemblyData.m_isSaved == true) {
-
- throw new InvalidOperationException(String.Format(CultureInfo.InvariantCulture, Environment.GetResourceString(ResId.InvalidOperation_AssemblyHasBeenSaved), nGetSimpleName()));
- }
-
- if ((m_assemblyData.m_access & AssemblyBuilderAccess.Save) != AssemblyBuilderAccess.Save) {
- throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_CantSaveTransientAssembly"));
- }
-
- if (assemblyFileName == null)
- throw new ArgumentNullException("assemblyFileName");
- if (assemblyFileName.Length == 0)
- throw new ArgumentException(Environment.GetResourceString("Argument_EmptyFileName"), "assemblyFileName");
- if (!String.Equals(assemblyFileName, Path.GetFileName(assemblyFileName)))
- throw new ArgumentException(Environment.GetResourceString("Argument_NotSimpleFileName"), "assemblyFileName");
-
-
- assemblyModule = m_assemblyData.FindModuleWithFileName(assemblyFileName);
-
- if (assemblyModule != null) {
-