本文整理汇总了C#中System.Reflection.Emit.ModuleBuilder.SetSymWriter方法的典型用法代码示例。如果您正苦于以下问题:C# ModuleBuilder.SetSymWriter方法的具体用法?C# ModuleBuilder.SetSymWriter怎么用?C# ModuleBuilder.SetSymWriter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Reflection.Emit.ModuleBuilder
的用法示例。
在下文中一共展示了ModuleBuilder.SetSymWriter方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DefineDynamicModuleInternalNoLock
[System.Security.SecurityCritical] // auto-generated
private ModuleBuilder DefineDynamicModuleInternalNoLock(
String name, // module name
String fileName, // module file name
bool emitSymbolInfo, // specify if emit symbol info or not
ref StackCrawlMark stackMark) // stack crawl mark used to find caller
{
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");
Contract.Ensures(Contract.Result<ModuleBuilder>() != null);
Contract.EndContractBlock();
BCLDebug.Log("DYNIL", "## DYNIL LOGGING: AssemblyBuilder.DefineDynamicModule( " + name + ", " + fileName + ", " + emitSymbolInfo + " )");
if (m_assemblyData.m_access == AssemblyBuilderAccess.Run)
{
// Error! You cannot define a persistable module within a transient data.
throw new NotSupportedException(Environment.GetResourceString("Argument_BadPersistableModuleInTransientAssembly"));
}
if (m_assemblyData.m_isSaved == true)
{
// assembly has been saved before!
throw new InvalidOperationException(Environment.GetResourceString(
"InvalidOperation_CannotAlterAssembly"));
}
ModuleBuilder dynModule;
ISymbolWriter writer = null;
IntPtr pInternalSymWriter = new IntPtr();
// create the dynamic module
m_assemblyData.CheckNameConflict(name);
m_assemblyData.CheckFileNameConflict(fileName);
int tkFile;
InternalModuleBuilder internalDynModule = (InternalModuleBuilder)DefineDynamicModule(
InternalAssembly,
emitSymbolInfo,
name,
fileName,
ref stackMark,
ref pInternalSymWriter,
false /*fIsTransient*/,
out tkFile);
dynModule = new ModuleBuilder(this, internalDynModule);
// initialize the dynamic module's managed side information
dynModule.Init(name, fileName, tkFile);
// Create the symbol writer
if (emitSymbolInfo)
{
// 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("MissingType", "SymWriter"));
}
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);
}
finally
{
CodeAccessPermission.RevertAssert();
}
}
dynModule.SetSymWriter(writer);
m_assemblyData.AddModule(dynModule);
return dynModule;
} // DefineDynamicModuleInternalNoLock
示例2: 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;
}