本文整理汇总了C#中System.Reflection.Emit.ModuleBuilder.Init方法的典型用法代码示例。如果您正苦于以下问题:C# ModuleBuilder.Init方法的具体用法?C# ModuleBuilder.Init怎么用?C# ModuleBuilder.Init使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Reflection.Emit.ModuleBuilder
的用法示例。
在下文中一共展示了ModuleBuilder.Init方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DefineDynamicModuleInternalNoLock
[System.Security.SecurityCritical] // auto-generated
private ModuleBuilder DefineDynamicModuleInternalNoLock(
String name,
bool emitSymbolInfo, // specify if emit symbol info or not
ref StackCrawlMark stackMark)
{
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");
Contract.Ensures(Contract.Result<ModuleBuilder>() != null);
Contract.EndContractBlock();
BCLDebug.Log("DYNIL", "## DYNIL LOGGING: AssemblyBuilder.DefineDynamicModule( " + name + " )");
Contract.Assert(m_assemblyData != null, "m_assemblyData is null in DefineDynamicModuleInternal");
ModuleBuilder dynModule;
ISymbolWriter writer = null;
IntPtr pInternalSymWriter = new IntPtr();
// create the dynamic module
#if FEATURE_MULTIMODULE_ASSEMBLIES
#if FEATURE_CORECLR
#error FEATURE_MULTIMODULE_ASSEMBLIES should always go with !FEATURE_CORECLR
#endif //FEATURE_CORECLR
m_assemblyData.CheckNameConflict(name);
if (m_fManifestModuleUsedAsDefinedModule == true)
{ // We need to define a new module
int tkFile;
InternalModuleBuilder internalDynModule = (InternalModuleBuilder)DefineDynamicModule(
InternalAssembly,
emitSymbolInfo,
name,
name,
ref stackMark,
ref pInternalSymWriter,
true /*fIsTransient*/,
out tkFile);
dynModule = new ModuleBuilder(this, internalDynModule);
// initialize the dynamic module's managed side information
dynModule.Init(name, null, tkFile);
}
else
{ // We will reuse the manifest module
m_manifestModuleBuilder.ModifyModuleName(name);
dynModule = m_manifestModuleBuilder;
if (emitSymbolInfo)
{
pInternalSymWriter = ModuleBuilder.nCreateISymWriterForDynamicModule(dynModule.InternalModule, name);
}
}
#else // FEATURE_MULTIMODULE_ASSEMBLIES
// Without FEATURE_MULTIMODULE_ASSEMBLIES only one ModuleBuilder per AssemblyBuilder can be created
if (m_fManifestModuleUsedAsDefinedModule == true)
throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_NoMultiModuleAssembly"));
// Init(...) has already been called on m_manifestModuleBuilder in InitManifestModule()
dynModule = m_manifestModuleBuilder;
#endif // FEATURE_MULTIMODULE_ASSEMBLIES
// Create the symbol writer
if (emitSymbolInfo)
{
#if FEATURE_MULTIMODULE_ASSEMBLIES && !FEATURE_CORECLR
// this is the code path for the desktop runtime
// create the default SymWriter
Assembly assem = LoadISymWrapper();
Type symWriter = assem.GetType("System.Diagnostics.SymbolStore.SymWriter", true, false);
if (symWriter != null && !symWriter.IsVisible)
symWriter = null;
if (symWriter == null)
{
// cannot find SymWriter - throw TypeLoadException since we couldnt find the type.
throw new TypeLoadException(Environment.GetResourceString(ResId.MissingType, "SymWriter"));
}
new SecurityPermission(SecurityPermissionFlag.UnmanagedCode).Demand();
try
{
(new PermissionSet(PermissionState.Unrestricted)).Assert();
writer = (ISymbolWriter)Activator.CreateInstance(symWriter);
// Set the underlying writer for the managed writer
// that we're using. Note that this function requires
// unmanaged code access.
writer.SetUnderlyingWriter(pInternalSymWriter);
}
//.........这里部分代码省略.........
示例2: InitManifestModule
[System.Security.SecurityCritical] // auto-generated
private void InitManifestModule()
{
InternalModuleBuilder modBuilder = (InternalModuleBuilder)nGetInMemoryAssemblyModule();
// Note that this ModuleBuilder cannot be used for RefEmit yet
// because it hasn't been initialized.
// However, it can be used to set the custom attribute on the Assembly
m_manifestModuleBuilder = new ModuleBuilder(this, modBuilder);
// We are only setting the name in the managed ModuleBuilderData here.
// The name in the underlying metadata will be set when the
// manifest module is created during nCreateDynamicAssembly.
// This name needs to stay in sync with that used in
// Assembly::Init to call ReflectionModule::Create (in VM)
m_manifestModuleBuilder.Init(AssemblyBuilder.MANIFEST_MODULE_NAME, null, 0);
m_fManifestModuleUsedAsDefinedModule = false;
}
示例3: GetOnDiskAssemblyModuleBuilder
[System.Security.SecurityCritical] // auto-generated
private ModuleBuilder GetOnDiskAssemblyModuleBuilder()
{
if (m_onDiskAssemblyModuleBuilder == null)
{
Module module = AssemblyBuilder.GetOnDiskAssemblyModule(InternalAssembly.GetNativeHandle());
ModuleBuilder modBuilder = new ModuleBuilder(this, (InternalModuleBuilder)module);
modBuilder.Init("RefEmit_OnDiskManifestModule", null, 0);
m_onDiskAssemblyModuleBuilder = modBuilder;
}
return m_onDiskAssemblyModuleBuilder;
}
示例4: GetOnDiskAssemblyModuleBuilder
private ModuleBuilder GetOnDiskAssemblyModuleBuilder()
{
if (this.m_onDiskAssemblyModuleBuilder == null)
{
Module onDiskAssemblyModule = GetOnDiskAssemblyModule(this.InternalAssembly.GetNativeHandle());
ModuleBuilder builder = new ModuleBuilder(this, (InternalModuleBuilder) onDiskAssemblyModule);
builder.Init("RefEmit_OnDiskManifestModule", null, 0);
this.m_onDiskAssemblyModuleBuilder = builder;
}
return this.m_onDiskAssemblyModuleBuilder;
}
示例5: DefineDynamicModuleInternalNoLock
private ModuleBuilder DefineDynamicModuleInternalNoLock(string name, string fileName, bool emitSymbolInfo, ref StackCrawlMark stackMark)
{
int num;
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");
}
if (this.m_assemblyData.m_access == AssemblyBuilderAccess.Run)
{
throw new NotSupportedException(Environment.GetResourceString("Argument_BadPersistableModuleInTransientAssembly"));
}
if (this.m_assemblyData.m_isSaved)
{
throw new InvalidOperationException(Environment.GetResourceString("InvalidOperation_CannotAlterAssembly"));
}
ISymbolWriter writer = null;
IntPtr pInternalSymWriter = new IntPtr();
this.m_assemblyData.CheckNameConflict(name);
this.m_assemblyData.CheckFileNameConflict(fileName);
InternalModuleBuilder internalModuleBuilder = (InternalModuleBuilder) DefineDynamicModule(this.InternalAssembly, emitSymbolInfo, name, fileName, ref stackMark, ref pInternalSymWriter, false, out num);
ModuleBuilder dynModule = new ModuleBuilder(this, internalModuleBuilder);
dynModule.Init(name, fileName, num);
if (emitSymbolInfo)
{
Type type = this.LoadISymWrapper().GetType("System.Diagnostics.SymbolStore.SymWriter", true, false);
if ((type != null) && !type.IsVisible)
{
type = null;
}
if (type == null)
{
throw new TypeLoadException(Environment.GetResourceString("MissingType", new object[] { "SymWriter" }));
}
try
{
new System.Security.PermissionSet(PermissionState.Unrestricted).Assert();
writer = (ISymbolWriter) Activator.CreateInstance(type);
writer.SetUnderlyingWriter(pInternalSymWriter);
}
finally
{
CodeAccessPermission.RevertAssert();
}
}
dynModule.SetSymWriter(writer);
this.m_assemblyData.AddModule(dynModule);
return dynModule;
}