本文整理汇总了C#中System.Reflection.Emit.AssemblyBuilder.GetName方法的典型用法代码示例。如果您正苦于以下问题:C# AssemblyBuilder.GetName方法的具体用法?C# AssemblyBuilder.GetName怎么用?C# AssemblyBuilder.GetName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Reflection.Emit.AssemblyBuilder
的用法示例。
在下文中一共展示了AssemblyBuilder.GetName方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TypeGenerator
static TypeGenerator()
{
var assemblyName = new AssemblyName { Name = "Siege.DynamicTypes" };
AppDomain thisDomain = Thread.GetDomain();
assemblyBuilder = thisDomain.DefineDynamicAssembly(assemblyName, AssemblyBuilderAccess.RunAndSave);
module = assemblyBuilder.DefineDynamicModule(assemblyBuilder.GetName().Name,
assemblyBuilder.GetName().Name +
".dll");
}
示例2: Verify
/// <summary>
/// Verifies an assembly based on an <see cref="AssemblyBuilder" /> instance.
/// </summary>
/// <param name="assemblyBuilder">The <see cref="AssemblyBuilder" /> instance.</param>
/// <exception cref="ArgumentNullException">Thrown if <c>assemblyBuilder</c> is <c>null</c>.</exception>
/// <exception cref="FileNotFoundException">Thrown if the given file does not exist.</exception>
/// <exception cref="VerificationException">Thrown if the assembly has verification errors.</exception>
public static void Verify(AssemblyBuilder assemblyBuilder)
{
var assemblyName = assemblyBuilder.GetName().Name;
assemblyName += assemblyBuilder.EntryPoint != null ? ".exe" : ".dll";
var localPath = new Uri(assemblyBuilder.GetName().CodeBase).LocalPath;
var directoryName = Path.GetDirectoryName(localPath);
if (directoryName != null)
InternalVerify(Path.Combine(directoryName, assemblyName));
}
示例3: EmitHelper
public EmitHelper()
{
string guid = Guid.NewGuid().ToString();
this.fileName = guid + ".dll";
AssemblyName assemblyName = new AssemblyName(guid);
assemblyBuilder = AppDomain.CurrentDomain.DefineDynamicAssembly(assemblyName, AssemblyBuilderAccess.Save);
module = assemblyBuilder.DefineDynamicModule(assemblyBuilder.GetName().Name, fileName, false);
}
示例4: Verify
/// <summary>
/// Verifies an assembly based on an <see cref="AssemblyBuilder" /> instance.
/// </summary>
/// <param name="assemblyBuilder">The <see cref="AssemblyBuilder" /> instance.</param>
/// <exception cref="ArgumentNullException">Thrown if <c>assemblyBuilder</c> is <c>null</c>.</exception>
/// <exception cref="FileNotFoundException">Thrown if the given file does not exist.</exception>
/// <exception cref="VerificationException">Thrown if the assembly has verification errors.</exception>
public static void Verify(AssemblyBuilder assemblyBuilder)
{
//assemblyBuilder.CheckParameterForNull("assemblyBuilder");
string assemblyName = assemblyBuilder.GetName().Name;
if(assemblyBuilder.EntryPoint != null)
{
assemblyName += ".exe";
}
else
{
assemblyName += ".dll";
}
AssemblyVerification.InternalVerify(Path.Combine(
Path.GetDirectoryName(new Uri(assemblyBuilder.GetName().CodeBase).LocalPath),
assemblyName));
}
示例5: Initialize
private void Initialize()
{
var name = new AssemblyName(outputFilename);
assemblyBuilder = AppDomain.CurrentDomain.DefineDynamicAssembly(name, AssemblyBuilderAccess.RunAndSave);
ModuleBuilder moduleBuilder = assemblyBuilder.DefineDynamicModule(assemblyBuilder.GetName().Name, outputPath,
true);
RootContext.InitializeForBuild(moduleBuilder);
}
示例6: AlgorithmCompiler
public AlgorithmCompiler(bool IsDecryptState)
{
this.IsDecryptState = IsDecryptState;
lock (GlobalLock)
{
if(assemblyName == null)
{
assemblyName = new AssemblyName();
assemblyName.Name = "__AlgorithmCompiler__" + GlobalInitialized++;
asmBuilder = AppDomain.CurrentDomain.DefineDynamicAssembly(assemblyName, AssemblyBuilderAccess.Run);
modBuilder = asmBuilder.DefineDynamicModule(asmBuilder.GetName().Name);
}
}
}
示例7: DynamicAssemblyInfo
public DynamicAssemblyInfo(string name)
{
var assemblyName = new AssemblyName(
name
);
_assemblyBuilder = Thread.GetDomain().DefineDynamicAssembly(
assemblyName,
AssemblyBuilderAccess.RunAndSave
);
_moduleBuilder = _assemblyBuilder.DefineDynamicModule(
_assemblyBuilder.GetName().Name,
false
);
}
示例8: Verify
public static void Verify(AssemblyBuilder assemblyBuilder)
{
if (assemblyBuilder == null)
{
throw new ArgumentNullException("assemblyBuilder");
}
var assemblyName = assemblyBuilder.GetName().Name;
if (assemblyBuilder.EntryPoint != null)
{
assemblyName += ".exe";
}
else
{
assemblyName += ".dll";
}
AssemblyVerification.Verify(Path.Combine(Directory.GetCurrentDirectory(), assemblyName));
}
示例9: InitializeAssembly
/// <summary>
/// Initialize static objects
/// </summary>
private static void InitializeAssembly()
{
//check to see if we've already instantiated
//the static objects
if (asmBuilder == null) {
//create a new dynamic assembly
AssemblyName assembly = new AssemblyName();
assembly.Name = "AnonymousTypeExentions";
//get the current application domain
AppDomain domain = Thread.GetDomain();
//get a module builder object
asmBuilder = domain.DefineDynamicAssembly(assembly,
AssemblyBuilderAccess.Run);
modBuilder = asmBuilder.DefineDynamicModule(
asmBuilder.GetName().Name, false
);
}
}
示例10: GenerateModuleBuilder
public ModuleBuilder GenerateModuleBuilder(AssemblyBuilder assemblyBuilder)
{
return assemblyBuilder.DefineDynamicModule(assemblyBuilder.GetName().Name, false);
}
示例11: InitializeCompiler
private void InitializeCompiler()
{
lock (_barrier)
{
if (_asm == null)
{
try
{
#if TRACE
_asm = AppDomain.CurrentDomain.DefineDynamicAssembly(new AssemblyName(Vault.GetAssemblyName()), AssemblyBuilderAccess.RunAndSave);
_mod = _asm.DefineDynamicModule(Vault.GetAssemblyName() + ".dll", true);
// do not use DomainUnload here because it never gets fired for default domain
AppDomain.CurrentDomain.ProcessExit += (o, e) =>
{
try
{
if (_asm != null)
{
_asm.Save(_asm.GetName().Name + ".dll");
}
}
catch(Exception ex)
{
MTLog.Say("Asm dumper has faced an unexpected exception: " + ex);
}
};
#else
_asm = AppDomain.CurrentDomain.DefineDynamicAssembly(new AssemblyName(Vault.GetClassName()), AssemblyBuilderAccess.Run);
_mod = _asm.DefineDynamicModule(Vault.GetClassName() + ".dll", false);
#endif
_asm.SetCustomAttribute(new CustomAttributeBuilder(
typeof(GuidAttribute).GetConstructors().Single(),
Vault.Id.ToString().MkArray()));
}
catch (Exception ex)
{
MTLog.Say("Compiler initialization failed: " + ex);
_isPermanentlyBroken = true;
}
}
}
GetCompiledAsync();
}
示例12: CreateModule
private static ModuleBuilder CreateModule(AssemblyBuilder builder)
{
var theName = builder.GetName();
return builder.DefineDynamicModule(theName.Name, theName.Name + ".dll");
}
示例13: SerializationMethodGeneratorManager
private SerializationMethodGeneratorManager( bool isDebuggable, bool isCollectable, AssemblyBuilder assemblyBuilder )
{
this._isDebuggable = isDebuggable;
string assemblyName;
if ( assemblyBuilder != null )
{
assemblyName =
#if !NETSTANDARD1_1 && !NETSTANDARD1_3
assemblyBuilder.GetName( false ).Name;
#else
assemblyBuilder.GetName().Name;
#endif // !NETSTANDARD1_1 && !NETSTANDARD1_3
this._assembly = assemblyBuilder;
}
else
{
assemblyName = typeof( SerializationMethodGeneratorManager ).Namespace + ".GeneratedSerealizers" + Interlocked.Increment( ref _assemblySequence );
var dedicatedAssemblyBuilder =
#if !NETSTANDARD1_1 && !NETSTANDARD1_3
AppDomain.CurrentDomain.DefineDynamicAssembly(
new AssemblyName( assemblyName ),
isDebuggable
? AssemblyBuilderAccess.RunAndSave
#if !NETFX_35
: ( isCollectable ? AssemblyBuilderAccess.RunAndCollect : AssemblyBuilderAccess.Run )
#else
: AssemblyBuilderAccess.Run
#endif // !NETFX_35
#if DEBUG
,
SerializerDebugging.DumpDirectory
#endif // DEBUG
);
#else
AssemblyBuilder.DefineDynamicAssembly(
new AssemblyName( assemblyName ),
isCollectable ? AssemblyBuilderAccess.RunAndCollect : AssemblyBuilderAccess.Run
);
#endif // !NETSTANDARD1_1 && !NETSTANDARD1_3
SetUpAssemblyBuilderAttributes( dedicatedAssemblyBuilder, isDebuggable );
this._assembly = dedicatedAssemblyBuilder;
}
#if !NETSTANDARD1_1 && !NETSTANDARD1_3
if ( isDebuggable )
{
this._module = this._assembly.DefineDynamicModule( assemblyName, assemblyName + ".dll", true );
}
else
{
this._module = this._assembly.DefineDynamicModule( assemblyName, true );
}
#else
this._module = this._assembly.DefineDynamicModule( assemblyName );
#endif // !NETSTANDARD1_1 && !NETSTANDARD1_3
}
示例14: Save
private static void Save(AssemblyBuilder assembly, ProxyContext context)
{
if ((context.Access & AssemblyBuilderAccess.Save) == AssemblyBuilderAccess.Save)
{
assembly.Save(assembly.GetName().Name + ".dll");
if (context.Verify)
{
AssemblyVerification.Verify(assembly);
}
}
}
示例15: DefaultSerializationMethodGeneratorManager
private DefaultSerializationMethodGeneratorManager( bool isDebuggable, bool isCollectable, AssemblyBuilder assemblyBuilder )
{
this._isDebuggable = isDebuggable;
string assemblyName;
if ( assemblyBuilder != null )
{
assemblyName = assemblyBuilder.GetName( false ).Name;
this._assembly = assemblyBuilder;
}
else
{
assemblyName = typeof( DefaultSerializationMethodGeneratorManager ).Namespace + ".GeneratedSerealizers" + Interlocked.Increment( ref _assemblySequence );
var dedicatedAssemblyBuilder =
AppDomain.CurrentDomain.DefineDynamicAssembly(
new AssemblyName( assemblyName ),
#if !SILVERLIGHT
isDebuggable
? AssemblyBuilderAccess.RunAndSave
#if !NETFX_35
: ( isCollectable ? AssemblyBuilderAccess.RunAndCollect : AssemblyBuilderAccess.Run )
#else
: AssemblyBuilderAccess.Run
#endif
#else
AssemblyBuilderAccess.Run
#endif
);
SetUpAssemblyBuilderAttributes( dedicatedAssemblyBuilder, isDebuggable );
this._assembly = dedicatedAssemblyBuilder;
}
#if SILVERLIGHT
this._module = this._assembly.DefineDynamicModule( assemblyName, true );
#else
if ( isDebuggable )
{
this._module = this._assembly.DefineDynamicModule( assemblyName, assemblyName + ".dll", true );
}
else
{
this._module = this._assembly.DefineDynamicModule( assemblyName, true );
}
#endif // else SILVERLIGHT
}