本文整理汇总了C#中System.AssemblyLoadEventArgs类的典型用法代码示例。如果您正苦于以下问题:C# AssemblyLoadEventArgs类的具体用法?C# AssemblyLoadEventArgs怎么用?C# AssemblyLoadEventArgs使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AssemblyLoadEventArgs类属于System命名空间,在下文中一共展示了AssemblyLoadEventArgs类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: LoadDebugging
void LoadDebugging(object sender, AssemblyLoadEventArgs args, string name)
{
// we'll output the full assemblyName
Console.WriteLine("{0} was loaded:", args.LoadedAssembly.FullName);
// can skip the first 2 frames,
// they just have the event handlers for assem load
StackTrace stackTrace = new StackTrace(2);
StackFrame[] frames = stackTrace.GetFrames();
// dump the stack
foreach (StackFrame frame in frames)
{
MethodBase method = frame.GetMethod();
ParameterInfo[] parameters = method.GetParameters();
StringBuilder parString = new StringBuilder();
for (int i = 0; i < parameters.Length; i++)
{
ParameterInfo par = parameters[i];
if (i > 0)
parString.Append(", ");
parString.Append(par.ParameterType.ToString());
}
Console.WriteLine(" at {0}.{1}({2})",
method.DeclaringType.Name,
method.Name,
parString.ToString());
}
}
示例2: CurrentDomain_AssemblyLoad
static void CurrentDomain_AssemblyLoad(object sender, AssemblyLoadEventArgs args)
{
Assembly assembly = args.LoadedAssembly;
lock (assemblies) {
assemblies[assembly.FullName] = assembly;
}
}
示例3: OnAssemblyLoad
private void OnAssemblyLoad(object sender, AssemblyLoadEventArgs args)
{
if (args.LoadedAssembly.GlobalAssemblyCache)
return;
Trace.TraceInformation("Assembly Loaded... {0}", args.LoadedAssembly.Location);
if (args.LoadedAssembly.Location.StartsWith(_pluginFolder.FullName, StringComparison.InvariantCultureIgnoreCase))
{
try
{
RegisterWithCheck(args.LoadedAssembly);
var types = args.LoadedAssembly.GetExportedTypes();
if (types.Any())
{
foreach (var type in types)
{
Trace.TraceInformation("Type exported: {0}", type.FullName);
}
}
else
{
Trace.TraceInformation("No types exported by Assembly: '{0}'",
args.LoadedAssembly.GetName().Name);
}
}
catch (Exception ex)
{
Trace.TraceInformation(ex.Message);
}
}
}
示例4: LoadDebugging
void LoadDebugging(object sender, AssemblyLoadEventArgs args, string name)
{
// can skip the first 2 frames,
// they just have the event handlers for assem load
StackTrace stackTrace = new StackTrace(2);
StackFrame[] frames = stackTrace.GetFrames();
// dump the stack
foreach (StackFrame frame in frames)
{
MethodBase method = frame.GetMethod();
ParameterInfo[] parameters = method.GetParameters();
StringBuilder parString = new StringBuilder();
for (int i = 0; i < parameters.Length; i++)
{
ParameterInfo par = parameters[i];
if (i > 0)
parString.Append(", ");
parString.Append(par.ParameterType.ToString());
}
//LoggerFactory.Default.Log(AssemblyLoadMonitorLogID, " at " + method.DeclaringType.Name + "." + method.Name + "(" + parString.ToString() + ")");
}
}
示例5: CurrentDomain_AssemblyLoad
/// <summary>
/// Handles the AssemblyLoad event of the AppDomain.
/// </summary>
/// <param name="sender">The source of the event.</param>
/// <param name="args">The <see cref="AssemblyLoadEventArgs"/> instance containing the event data.</param>
private void CurrentDomain_AssemblyLoad(object sender, AssemblyLoadEventArgs args)
{
lock (this)
{
UpdateMap();
}
}
示例6: OnAssemblyLoaded
private static void OnAssemblyLoaded(object sender, AssemblyLoadEventArgs args)
{
_assembliesByName[args.LoadedAssembly.FullName] = args.LoadedAssembly;
_assembliesByIndex.Add(args.LoadedAssembly);
_cachedTypes = new Dictionary<string, Type>();
}
示例7: OnAssemblyLoad
private void OnAssemblyLoad(object sender, AssemblyLoadEventArgs args) {
Assembly a = args.LoadedAssembly;
// Ignore GAC assemblies
if (a.GlobalAssemblyCache)
return;
// Ignore assemblies that don't start with our prefix
string name = a.GetName().Name;
if (!StringUtil.StringStartsWith(name, BuildManager.AssemblyNamePrefix))
return;
// Go through all the assemblies it references
foreach (AssemblyName assemblyName in a.GetReferencedAssemblies()) {
// Ignore references that don't start with our prefix
if (!StringUtil.StringStartsWith(assemblyName.Name, BuildManager.AssemblyNamePrefix))
continue;
lock (_dependentAssemblies) {
// Check whether we already have an ArrayList for this reference
ArrayList dependentList = _dependentAssemblies[assemblyName.Name] as ArrayList;
if (dependentList == null) {
// If not, create one and add it to the hashtable
dependentList = new ArrayList();
_dependentAssemblies[assemblyName.Name] = dependentList;
}
// Add the assembly that just got loaded as a dependent
Debug.Assert(!dependentList.Contains(name));
dependentList.Add(name);
}
}
}
示例8: AssemblyLoaded
private void AssemblyLoaded(object sender, AssemblyLoadEventArgs args) {
// !!! BUG on .Net 2 SP1: going further breaks DefineDynamicAssembly in very strange manner, so don't process dynamic assemblies
// simple test:
// AppDomain.CurrentDomain.DefineDynamicAssembly(new System.Reflection.AssemblyName("dynBoxed" + Guid.NewGuid().ToString()), System.Reflection.Emit.AssemblyBuilderAccess.Run);
// previous workaround using RegisterAssemblyForNonAutoRegistration/ShouldSkipAssemblyTypeAutoRegistration
// is deficient, there may be dynamic assemblies irrelevant to IIOPNet.
// So this patch is simple and universal:
if (args.LoadedAssembly is System.Reflection.Emit.AssemblyBuilder)
return;
RegisterTypes(args.LoadedAssembly);
AssemblyName[] refAssemblies =
args.LoadedAssembly.GetReferencedAssemblies();
if (refAssemblies != null) {
for (int i = 0; i <refAssemblies.Length; i++) {
try {
if (refAssemblies[i] != null) {
Assembly.Load(refAssemblies[i]); // this will call AssemblyLoaded for this assembly
}
} catch (BadImageFormatException) {
Trace.WriteLine("bad format -> ignoring assembly " + refAssemblies[i].FullName);
// ignore assembly
} catch (FileNotFoundException) {
Trace.WriteLine("missing -> ignoring assembly " + refAssemblies[i].FullName);
// ignore assembly
} catch (System.Security.SecurityException) {
Trace.WriteLine("security problem -> ignoring assembly " + refAssemblies[i].FullName);
// ignore assembly
}
}
}
}
示例9: CurrentDomain_AssemblyLoad
void CurrentDomain_AssemblyLoad(object sender, AssemblyLoadEventArgs args)
{
foreach (var type in args.LoadedAssembly.GetTypes().Where(
type => type.GetCustomAttributes(typeof(GuidAttribute), true).Any()))
{
this.types.TryAdd(type.GUID, type);
}
}
示例10: CurrentDomain_AssemblyLoad
private void CurrentDomain_AssemblyLoad(object sender, AssemblyLoadEventArgs args)
{
if (IsPluginAssembly(args.LoadedAssembly))
{
var plugin = CreatePluginFromAssembly(args.LoadedAssembly);
PublishPlugin(plugin);
}
}
示例11: AssemblyLoaded
#pragma warning restore 1591 // Xml Comments
void AssemblyLoaded(object sender, AssemblyLoadEventArgs args)
{
var assembly = args.LoadedAssembly;
if (!assembly.IsDynamic)
{
AvailableAssemblies.Add(AssemblyInfoFromAssembly(assembly));
}
}
示例12: OnAssemblyLoad
private static void OnAssemblyLoad(object sender, AssemblyLoadEventArgs args)
{
var asm = args.LoadedAssembly;
if (!asm.IsDynamic)
{
Log.LogVerbose(nameof(PackageAssemblyHandler), $"Assembly loaded: {asm.Location}");
}
}
示例13: AssemblyLoadedInCurrentDomain
public void AssemblyLoadedInCurrentDomain()
{
AssemblyLoadEventArgs assemblyEvent = new AssemblyLoadEventArgs(Assembly.GetAssembly(GetType()));
BinaryDataFactory binaryDataFactory = new BinaryDataFactory();
binaryDataFactory.OnAssemblyLoadInCurrentDomain(null, assemblyEvent);
Assert.That(binaryDataFactory.shortNames.Count, Is.GreaterThanOrEqualTo(4));
Assert.That(binaryDataFactory.typeMap.Count, Is.GreaterThanOrEqualTo(4));
}
示例14: CurrentDomain_AssemblyLoad
static void CurrentDomain_AssemblyLoad(object sender, AssemblyLoadEventArgs args)
{
if (!args.LoadedAssembly.GetName().Name.Contains("Proxies_"))
{
ConsoleColor CurrentColor = Console.ForegroundColor;
Console.ForegroundColor = ConsoleColor.Yellow;
Console.WriteLine(string.Format("Loading {0}.dll", args.LoadedAssembly.GetName().Name));
Console.ForegroundColor = CurrentColor;
}
}
示例15: CurrentDomain_AssemblyLoad
private static void CurrentDomain_AssemblyLoad(object sender, AssemblyLoadEventArgs args)
{
try
{
Logger.Log.DebugFormat("Assembly loaded: {0}", args.LoadedAssembly);
}
catch
{
}
}