本文整理汇总了C#中System.Reflection.AssemblyName.IsSystemAssembly方法的典型用法代码示例。如果您正苦于以下问题:C# AssemblyName.IsSystemAssembly方法的具体用法?C# AssemblyName.IsSystemAssembly怎么用?C# AssemblyName.IsSystemAssembly使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Reflection.AssemblyName
的用法示例。
在下文中一共展示了AssemblyName.IsSystemAssembly方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ResolveFrameworkAssemblyVersioning
/// <summary>
/// An event handler for resolving Silverlight framework assembly versioning.
/// </summary>
/// <remarks>
/// When a previous version of a Silverlight assembly is sought, the targeted version
/// of that Silverlight assembly will be returned.
/// </remarks>
/// <param name="sender">The event sender.</param>
/// <param name="args">The assembly resolution event arguments.</param>
/// <returns>The <see cref="Assembly"/> from the targeted version of Silverlight, or <c>null</c>.</returns>
private static Assembly ResolveFrameworkAssemblyVersioning(object sender, ResolveEventArgs args)
{
FrameworkManifest frameworkManifest = (FrameworkManifest)AppDomain.CurrentDomain.GetData(AppDomainUtilities.FrameworkManifestKey);
System.Diagnostics.Debug.Assert(frameworkManifest != null, "The FrameworkManifest must have been set on the AppDomain");
AssemblyName requestedAssembly = new AssemblyName(args.Name);
// If the requested assembly is a System assembly and it's an older version
// than the framework manifest has, then we'll need to resolve to its newer version
bool isOldVersion = requestedAssembly.Version.CompareTo(frameworkManifest.SystemVersion) < 0;
if (isOldVersion && requestedAssembly.IsSystemAssembly())
{
// Now we need to see if the requested assembly is part of the framework manifest (as opposed to an SDK assembly)
var silverlightAssembly = (from assembly in frameworkManifest.Assemblies
where assembly.Name == requestedAssembly.Name
select assembly).SingleOrDefault();
// If the assembly is part of the framework manifest, then we need to "redirect" its resolution
// to the current framework version.
if (silverlightAssembly != null)
{
// Find the Silverlight framework assembly from the already-loaded assemblies
var matches = from assembly in AppDomain.CurrentDomain.ReflectionOnlyGetAssemblies()
let assemblyName = assembly.GetName()
where assemblyName.Name == silverlightAssembly.Name
&& assemblyName.GetPublicKeyToken().SequenceEqual(silverlightAssembly.PublicKeyTokenBytes)
&& assemblyName.Version.CompareTo(silverlightAssembly.Version) == 0
select assembly;
return matches.SingleOrDefault();
}
}
return null;
}